diff --git a/.github/workflows/python-examples.yml b/.github/workflows/python-examples.yml index 3a8aa1d188a1..dfdd714afe27 100644 --- a/.github/workflows/python-examples.yml +++ b/.github/workflows/python-examples.yml @@ -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 & diff --git a/examples/python/tests/browsers/test_chrome.py b/examples/python/tests/browsers/test_chrome.py index 5f29881e8511..a972bc209a36 100644 --- a/examples/python/tests/browsers/test_chrome.py +++ b/examples/python/tests/browsers/test_chrome.py @@ -4,8 +4,6 @@ from selenium import webdriver -CHROME_LOCATION = os.getenv("CHROME_BIN") - def test_basic_options(): options = webdriver.ChromeOptions() @@ -25,10 +23,10 @@ def test_args(): driver.quit() -def test_set_browser_location(): +def test_set_browser_location(chrome_bin): options = webdriver.ChromeOptions() - options.binary_location = CHROME_LOCATION + options.binary_location = chrome_bin driver = webdriver.Chrome(options=options) diff --git a/examples/python/tests/browsers/test_edge.py b/examples/python/tests/browsers/test_edge.py index 0e160a249043..f99d44ecd33c 100644 --- a/examples/python/tests/browsers/test_edge.py +++ b/examples/python/tests/browsers/test_edge.py @@ -5,8 +5,6 @@ import pytest from selenium import webdriver -EDGE_LOCATION = os.getenv("EDGE_BIN") - def test_basic_options(): options = webdriver.EdgeOptions() @@ -26,10 +24,10 @@ def test_args(): driver.quit() -def test_set_browser_location(): +def test_set_browser_location(edge_bin): options = webdriver.EdgeOptions() - options.binary_location = EDGE_LOCATION + options.binary_location = edge_bin driver = webdriver.Edge(options=options) diff --git a/examples/python/tests/browsers/test_firefox.py b/examples/python/tests/browsers/test_firefox.py index c2dabed82643..925bd5e457fb 100644 --- a/examples/python/tests/browsers/test_firefox.py +++ b/examples/python/tests/browsers/test_firefox.py @@ -5,8 +5,6 @@ import pytest from selenium import webdriver -FIREFOX_LOCATION = os.getenv("FF_BIN") - def test_basic_options(): options = webdriver.FirefoxOptions() @@ -24,10 +22,10 @@ def test_arguments(): driver.quit() -def test_set_browser_location(): +def test_set_browser_location(firefox_bin): options = webdriver.FirefoxOptions() - options.binary_location = FIREFOX_LOCATION + options.binary_location = firefox_bin driver = webdriver.Firefox(options=options) diff --git a/examples/python/tests/conftest.py b/examples/python/tests/conftest.py index 56a61ea466f8..88fe0b716c8f 100644 --- a/examples/python/tests/conftest.py +++ b/examples/python/tests/conftest.py @@ -17,10 +17,37 @@ def driver(): @pytest.fixture(scope='function') -def chromedriver_path(): +def chromedriver_bin(): service = webdriver.chrome.service.Service() options = webdriver.ChromeOptions() - return webdriver.common.driver_finder.DriverFinder().get_path(service=service, options=options) + yield webdriver.common.driver_finder.DriverFinder().get_path(service=service, options=options) + + +@pytest.fixture(scope='function') +def chrome_bin(): + service = webdriver.chrome.service.Service() + options = webdriver.ChromeOptions() + options.browser_version = 'stable' + webdriver.common.driver_finder.DriverFinder().get_path(service=service, options=options) + yield options.binary_location + + +@pytest.fixture(scope='function') +def edge_bin(): + service = webdriver.edge.service.Service() + options = webdriver.EdgeOptions() + options.browser_version = 'stable' + webdriver.common.driver_finder.DriverFinder().get_path(service=service, options=options) + yield options.binary_location + + +@pytest.fixture(scope='function') +def firefox_bin(): + service = webdriver.firefox.service.Service() + options = webdriver.FirefoxOptions() + options.browser_version = 'stable' + webdriver.common.driver_finder.DriverFinder().get_path(service=service, options=options) + yield options.binary_location @pytest.fixture(scope='function')