Skip to content

Commit

Permalink
remove unnecessary things python
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 2, 2023
1 parent 396537f commit 880f7b9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 55 deletions.
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
6 changes: 2 additions & 4 deletions examples/python/tests/browsers/test_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from selenium import webdriver

CHROME_LOCATION = os.getenv("CHROME_BIN")


def test_basic_options():
options = webdriver.ChromeOptions()
Expand All @@ -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)

Expand Down
6 changes: 2 additions & 4 deletions examples/python/tests/browsers/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import pytest
from selenium import webdriver

EDGE_LOCATION = os.getenv("EDGE_BIN")


def test_basic_options():
options = webdriver.EdgeOptions()
Expand All @@ -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)

Expand Down
6 changes: 2 additions & 4 deletions examples/python/tests/browsers/test_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import pytest
from selenium import webdriver

FIREFOX_LOCATION = os.getenv("FF_BIN")


def test_basic_options():
options = webdriver.FirefoxOptions()
Expand All @@ -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)

Expand Down
31 changes: 29 additions & 2 deletions examples/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 880f7b9

Please sign in to comment.