Skip to content

Commit

Permalink
use driver finder for all binary location
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 2, 2023
1 parent 5fc5d42 commit 8f83ae4
Show file tree
Hide file tree
Showing 58 changed files with 1,113 additions and 1,156 deletions.
31 changes: 2 additions & 29 deletions .github/workflows/dotnet-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,14 @@ jobs:
steps:
- name: Checkout GitHub repo
uses: actions/checkout@v3
- name: Install Chrome for set binary test
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
id: setup-chrome
- name: Install Edge for set binary test
uses: browser-actions/setup-edge@v1
with:
edge-version: stable
id: setup-edge
- name: Install Firefox for set binary test
if: matrix.os != 'windows-latest'
uses: browser-actions/setup-firefox@v1
with:
firefox-version: latest
id: setup-firefox
- name: Set ENV Windows
if: matrix.os == 'windows-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV
echo "EDGE_BIN=${{ steps.setup-edge.outputs.edge-path }}" >> $env:GITHUB_ENV
- name: Set ENV Other
if: matrix.os != 'windows-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=${{ steps.setup-edge.outputs.edge-path }}" >> "$GITHUB_ENV"
echo "FF_BIN=${{ steps.setup-firefox.outputs.firefox-path }}" >> "$GITHUB_ENV"
- name: Remove driver directories Windows
if: matrix.os == 'windows'
if: matrix.os == 'windows-latest'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows'
if: matrix.os != 'windows-latest'
run: |
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
- name: Start Xvfb
Expand Down
38 changes: 2 additions & 36 deletions .github/workflows/java-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,14 @@ jobs:
steps:
- name: Checkout GitHub repo
uses: actions/checkout@v3
- name: Install Chrome for set binary test
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
id: setup-chrome
- name: Install Edge for set binary test
uses: browser-actions/setup-edge@v1
with:
edge-version: stable
id: setup-edge
- name: Install Firefox for set binary test
if: matrix.os != 'windows-latest'
uses: browser-actions/setup-firefox@v1
with:
firefox-version: latest
id: setup-firefox
- name: Set ENV Windows
if: matrix.os == 'windows-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV
echo "EDGE_BIN=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" >> $env:GITHUB_ENV
echo "FF_BIN=C:\Program Files (x86)\Mozilla Firefox\firefox-browser.exe" >> $env:GITHUB_ENV
- name: Set ENV Mac
if: matrix.os == 'macos-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=/Users/runner/hostedtoolcache/msedge/stable/x64/Contents/MacOS/Microsoft Edge" >> "$GITHUB_ENV"
echo "FF_BIN=/Users/runner/hostedtoolcache/firefox/latest/x64/Contents/MacOS/firefox" >> "$GITHUB_ENV"
- name: Set ENV Linux
if: matrix.os == 'ubuntu-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=/opt/hostedtoolcache/msedge/stable/x64/msedge" >> "$GITHUB_ENV"
echo "FF_BIN=/opt/hostedtoolcache/firefox/latest/x64/firefox" >> "$GITHUB_ENV"
- name: Remove driver directories Windows
if: matrix.os == 'windows'
if: matrix.os == 'windows-latest'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows'
if: matrix.os != 'windows-latest'
run: |
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
- name: Start Xvfb
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/js-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ jobs:
echo "EDGE_BIN=/opt/hostedtoolcache/msedge/stable/x64/msedge" >> "$GITHUB_ENV"
echo "FF_BIN=/opt/hostedtoolcache/firefox/latest/x64/firefox" >> "$GITHUB_ENV"
- name: Remove driver directories Windows
if: matrix.os == 'windows'
if: matrix.os == 'windows-latest'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows'
if: matrix.os != 'windows-latest'
run: |
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
- name: Start Xvfb
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/kotlin-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ jobs:
echo "EDGE_BIN=/opt/hostedtoolcache/msedge/stable/x64/msedge" >> "$GITHUB_ENV"
echo "FF_BIN=/opt/hostedtoolcache/firefox/latest/x64/firefox" >> "$GITHUB_ENV"
- name: Remove driver directories Windows
if: matrix.os == 'windows'
if: matrix.os == 'windows-latest'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows'
if: matrix.os != 'windows-latest'
run: |
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
- name: Start Xvfb
Expand Down
48 changes: 7 additions & 41 deletions .github/workflows/python-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,16 @@ jobs:
steps:
- name: Checkout GitHub repo
uses: actions/checkout@v3
- name: Install Chrome for set binary test
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
id: setup-chrome
- name: Install Edge for set binary test
uses: browser-actions/setup-edge@v1
with:
edge-version: stable
id: setup-edge
- name: Install Firefox for set binary test
if: matrix.os != 'windows-latest'
uses: browser-actions/setup-firefox@v1
with:
firefox-version: latest
id: setup-firefox
- name: Set ENV Windows
- name: Remove driver directories Windows
if: matrix.os == 'windows-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV
echo "EDGE_BIN=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" >> $env:GITHUB_ENV
echo "FF_BIN=C:\Program Files (x86)\Mozilla Firefox\firefox-browser.exe" >> $env:GITHUB_ENV
- name: Set ENV Mac
if: matrix.os == 'macos-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=/Users/runner/hostedtoolcache/msedge/stable/x64/Contents/MacOS/Microsoft Edge" >> "$GITHUB_ENV"
echo "FF_BIN=/Users/runner/hostedtoolcache/firefox/latest/x64/Contents/MacOS/firefox" >> "$GITHUB_ENV"
- name: Set ENV Linux
if: matrix.os == 'ubuntu-latest'
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=/opt/hostedtoolcache/msedge/stable/x64/msedge" >> "$GITHUB_ENV"
echo "FF_BIN=/opt/hostedtoolcache/firefox/latest/x64/firefox" >> "$GITHUB_ENV"
- name: Remove driver directories Windows
if: matrix.os == 'windows'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows'
run: |
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
- name: Start Xvfb
if: matrix.os == 'ubuntu-latest'
run: Xvfb :99 &
Expand Down
38 changes: 2 additions & 36 deletions .github/workflows/ruby-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,14 @@ jobs:
steps:
- name: Checkout GitHub repo
uses: actions/checkout@v3
- name: Install Chrome for set binary test
uses: browser-actions/setup-chrome@v1
with:
chrome-version: stable
id: setup-chrome
- name: Install Edge for set binary test
uses: browser-actions/setup-edge@v1
with:
edge-version: stable
id: setup-edge
- name: Install Firefox for set binary test
if: matrix.os != 'windows-latest'
uses: browser-actions/setup-firefox@v1
with:
firefox-version: latest
id: setup-firefox
- name: Set ENV Windows
if: matrix.os == 'windows-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> $env:GITHUB_ENV
echo "EDGE_BIN=C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" >> $env:GITHUB_ENV
echo "FF_BIN=C:\Program Files (x86)\Mozilla Firefox\firefox-browser.exe" >> $env:GITHUB_ENV
- name: Set ENV Mac
if: matrix.os == 'macos-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=/Users/runner/hostedtoolcache/msedge/stable/x64/Contents/MacOS/Microsoft Edge" >> "$GITHUB_ENV"
echo "FF_BIN=/Users/runner/hostedtoolcache/firefox/latest/x64/Contents/MacOS/firefox" >> "$GITHUB_ENV"
- name: Set ENV Linux
if: matrix.os == 'ubuntu-latest'
run: |
echo "CHROME_BIN=${{ steps.setup-chrome.outputs.chrome-path }}" >> "$GITHUB_ENV"
echo "EDGE_BIN=/opt/hostedtoolcache/msedge/stable/x64/msedge" >> "$GITHUB_ENV"
echo "FF_BIN=/opt/hostedtoolcache/firefox/latest/x64/firefox" >> "$GITHUB_ENV"
- name: Remove driver directories Windows
if: matrix.os == 'windows'
if: matrix.os == 'windows-latest'
run: |
rm "$env:ChromeWebDriver" -r -v
rm "$env:EdgeWebDriver" -r -v
rm "$env:GeckoWebDriver" -r -v
- name: Remove driver directories Non-Windows
if: matrix.os != 'windows'
if: matrix.os != 'windows-latest'
run: |
sudo rm -rf $CHROMEWEBDRIVER $EDGEWEBDRIVER $GECKOWEBDRIVER
- name: Start Xvfb
Expand Down
9 changes: 7 additions & 2 deletions examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ private string GetLogLocation()
return _logLocation;
}

private string GetChromeLocation()
private static string GetChromeLocation()
{
return Environment.GetEnvironmentVariable("CHROME_BIN");
var options = new ChromeOptions
{
BrowserVersion = "stable"
};
DriverFinder.FullPath(options);
return options.BinaryLocation;
}
}
}
9 changes: 7 additions & 2 deletions examples/dotnet/SeleniumDocs/Browsers/EdgeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ private string GetLogLocation()
return _logLocation;
}

private string GetEdgeLocation()
private static string GetEdgeLocation()
{
return Environment.GetEnvironmentVariable("EDGE_BIN");
var options = new EdgeOptions
{
BrowserVersion = "stable"
};
DriverFinder.FullPath(options);
return options.BinaryLocation;
}
}
}
9 changes: 7 additions & 2 deletions examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,14 @@ private void SetWaitingDriver()
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);
}

private string GetFirefoxLocation()
private static string GetFirefoxLocation()
{
return Environment.GetEnvironmentVariable("FF_BIN");
var options = new FirefoxOptions()
{
BrowserVersion = "stable"
};
DriverFinder.FullPath(options);
return options.BinaryLocation;
}
}
}
17 changes: 13 additions & 4 deletions examples/dotnet/SeleniumDocs/Drivers/ServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public void BasicService()
[TestMethod]
public void DriverLocation()
{
var service = ChromeDriverService.CreateDefaultService(GetDriverLocation());
var options = GetLatestChromeOptions();
var service = ChromeDriverService.CreateDefaultService(GetDriverLocation(options));

driver = new ChromeDriver(service);
driver = new ChromeDriver(service, options);
}

[TestMethod]
Expand All @@ -35,9 +36,17 @@ public void DriverPort()
driver = new ChromeDriver(service);
}

private string GetDriverLocation()
private static string GetDriverLocation(ChromeOptions options)
{
return DriverFinder.FullPath(options);
}

private static ChromeOptions GetLatestChromeOptions()
{
return DriverFinder.FullPath(new ChromeOptions());
return new ChromeOptions
{
BrowserVersion = "stable"
};
}
}
}
12 changes: 4 additions & 8 deletions examples/java/src/test/java/dev/selenium/BaseChromeTest.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package dev.selenium;

import org.junit.jupiter.api.BeforeEach;
import org.openqa.selenium.chrome.ChromeDriver;

public class BaseChromeTest extends BaseTest {

@BeforeEach
public void setup() {
System.setProperty("webdriver.chrome.logfile", "chromedriver.log");
System.setProperty("webdriver.chrome.verboseLogging", "true");
driver = new ChromeDriver();
}

@BeforeEach
public void setup() {
startChromeDriver();
}
}
10 changes: 4 additions & 6 deletions examples/java/src/test/java/dev/selenium/BaseFirefoxTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package dev.selenium;

import org.junit.jupiter.api.BeforeEach;
import org.openqa.selenium.firefox.FirefoxDriver;

public class BaseFirefoxTest extends BaseTest {

@BeforeEach
public void setup() {
driver = new FirefoxDriver();
}

@BeforeEach
public void setup() {
startFirefoxDriver();
}
}
Loading

0 comments on commit 8f83ae4

Please sign in to comment.