add edge(chromium) support

This commit is contained in:
Greg Gauthier 2020-10-10 23:27:46 +01:00
parent 6ac43e67bf
commit 9cb7263047
3 changed files with 20 additions and 4 deletions

View File

@ -9,6 +9,7 @@ pytest = "*"
behave = "*"
selenium = "*"
webdriver_manager = "*"
msedge-selenium-tools = "*"
[packages]
flask = "*"
@ -16,6 +17,7 @@ pytest = "*"
behave = "*"
selenium = "*"
webdriver_manager = "*"
msedge-selenium-tools = "*"
[requires]
python_version = "3.8"

View File

@ -1,8 +1,9 @@
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
from msedge.selenium_tools import Edge, EdgeOptions
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager
class BrowserDriver:
@ -13,7 +14,7 @@ class BrowserDriver:
elif browser == "firefox":
return firefox(headless)
elif browser == "edge":
return edge()
return edge(headless)
elif browser == "safari":
return safari()
else:
@ -39,8 +40,13 @@ def firefox(headless=True):
options=options)
def edge():
return webdriver.Edge(DesiredCapabilities.EDGE)
def edge(headless=True):
options = EdgeOptions()
options.use_chromium = True
options.headless = headless
edge_driver = EdgeChromiumDriverManager().install()
driver = Edge(edge_driver, options=options)
return driver
def safari():

View File

@ -15,3 +15,11 @@ def test_chrome_browser(headless):
print(bd.current_url, bd.title)
assert "QA Testing as a Service | test IO" == bd.title
bd.quit()
def test_edge_browser(headless):
bd = BrowserDriver().get("edge", headless=headless)
bd.get('https://test.io')
print(bd.current_url, bd.title)
assert "QA Testing as a Service | test IO" == bd.title
bd.quit()