attempted fix for msedge driver
Some checks failed
Execute / build (3.12) (push) Failing after 8s
Pylint / build (3.12) (push) Failing after 11s

This commit is contained in:
Greg Gauthier 2024-07-23 18:05:15 +01:00
parent 0f8388e08c
commit c33ed44780
6 changed files with 27 additions and 5 deletions

View File

@ -26,8 +26,10 @@ jobs:
run: | run: |
wget https://msedgedriver.azureedge.net/${EDGEDRIVER_VERSION}/edgedriver_win64.zip wget https://msedgedriver.azureedge.net/${EDGEDRIVER_VERSION}/edgedriver_win64.zip
unzip edgedriver_win64.zip unzip edgedriver_win64.zip
mv msedgedriver drivers
- name: Run the pytests - name: Run the pytests
run: pytest -c pytest.ini run: pytest -c pytest.ini -m edge
- name: Run the behave tests - name: Run the behave tests
run: behave run: behave

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
.idea/ .idea/
.vscode/ .vscode/
.venv/ .venv/
drivers/

View File

@ -1,8 +1,13 @@
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
import platform
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.edge.options import Options as EdgeOptions from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.edge.service import Service as EdgeService
from conftest import CWD
import os
class BrowserDriver: class BrowserDriver:
@ -35,12 +40,17 @@ def firefox(headless=True):
def edge(headless=True): def edge(headless=True):
options = EdgeOptions() options = EdgeOptions()
driver_name = "msedgedriver"
if platform.system() == 'Windows':
driver_name += ".exe"
edgedriver_loc = os.path.join(CWD, 'drivers', driver_name)
options.use_chromium = True options.use_chromium = True
options.add_argument('disable-gpu') options.add_argument('disable-gpu')
if headless: if headless:
options.add_argument('headless') options.add_argument('headless')
edge_driver = webdriver.Edge(options=options) edge_service = EdgeService(executable_path=edgedriver_loc)
print(edge_driver.service.path) edge_driver = webdriver.Edge(service=edge_service, options=options)
return edge_driver return edge_driver

BIN
edgedriver_win64.zip Normal file

Binary file not shown.

View File

@ -1,3 +1,7 @@
[pytest] [pytest]
addopts = -s
testpaths = pytests testpaths = pytests
markers =
chrome: chrome tests only.
firefox: firefox tests only.
edge: msedge tests only.

View File

@ -1,8 +1,10 @@
import pytest import pytest
from browserdriver import BrowserDriver from browserdriver import BrowserDriver
from conftest import CWD
@pytest.mark.firefox
def test_firefox_browser(headless): def test_firefox_browser(headless):
bd = BrowserDriver().get("firefox", headless=headless) bd = BrowserDriver().get("firefox", headless=headless)
bd.get('https://test.io') bd.get('https://test.io')
@ -10,6 +12,7 @@ def test_firefox_browser(headless):
bd.quit() bd.quit()
@pytest.mark.chrome
def test_chrome_browser(headless): def test_chrome_browser(headless):
bd = BrowserDriver().get("chrome", headless=headless) bd = BrowserDriver().get("chrome", headless=headless)
bd.get('https://test.io') bd.get('https://test.io')
@ -25,8 +28,10 @@ def test_safari_browser():
bd.quit() bd.quit()
@pytest.mark.edge
def test_edge_browser(headless): def test_edge_browser(headless):
bd = BrowserDriver().get("edge", headless=headless) bd = BrowserDriver().get("edge", headless=headless)
bd.get('https://test.io') bd.get('https://test.io')
assert bd.title == "Home | Test IO" assert bd.title == "Home | Test IO"
bd.quit() bd.quit()