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 = "*" behave = "*"
selenium = "*" selenium = "*"
webdriver_manager = "*" webdriver_manager = "*"
msedge-selenium-tools = "*"
[packages] [packages]
flask = "*" flask = "*"
@ -16,6 +17,7 @@ pytest = "*"
behave = "*" behave = "*"
selenium = "*" selenium = "*"
webdriver_manager = "*" webdriver_manager = "*"
msedge-selenium-tools = "*"
[requires] [requires]
python_version = "3.8" python_version = "3.8"

View File

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

View File

@ -15,3 +15,11 @@ def test_chrome_browser(headless):
print(bd.current_url, bd.title) print(bd.current_url, bd.title)
assert "QA Testing as a Service | test IO" == bd.title assert "QA Testing as a Service | test IO" == bd.title
bd.quit() 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()