set the driver to headless, and add different tests for chrome and firefox
This commit is contained in:
parent
77dc32f142
commit
fc4cd7107c
@ -7,6 +7,6 @@ logging-level=ERROR
|
|||||||
|
|
||||||
[behave.userdata]
|
[behave.userdata]
|
||||||
browser = chrome
|
browser = chrome
|
||||||
|
headless = True
|
||||||
name = gmgauthier@protonmail.com
|
name = gmgauthier@protonmail.com
|
||||||
platform = OSX
|
platform = OSX
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class BrowserDriver:
|
|||||||
|
|
||||||
def chrome():
|
def chrome():
|
||||||
options = webdriver.ChromeOptions()
|
options = webdriver.ChromeOptions()
|
||||||
|
options.headless = True
|
||||||
options.add_argument('--ignore-certificate-errors')
|
options.add_argument('--ignore-certificate-errors')
|
||||||
return webdriver.Chrome(ChromeDriverManager().install(), options=options)
|
return webdriver.Chrome(ChromeDriverManager().install(), options=options)
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ def chrome():
|
|||||||
def firefox():
|
def firefox():
|
||||||
options = webdriver.FirefoxOptions()
|
options = webdriver.FirefoxOptions()
|
||||||
options.accept_insecure_certs = True
|
options.accept_insecure_certs = True
|
||||||
|
options.headless = True
|
||||||
gecko_driver = GeckoDriverManager().install()
|
gecko_driver = GeckoDriverManager().install()
|
||||||
return webdriver.Firefox(executable_path=gecko_driver, firefox_options=options)
|
return webdriver.Firefox(executable_path=gecko_driver, firefox_options=options)
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ def pytest_addoption(parser):
|
|||||||
action='store',
|
action='store',
|
||||||
default='staging',
|
default='staging',
|
||||||
help='the name of the environment for which you need properties.')
|
help='the name of the environment for which you need properties.')
|
||||||
parser.addoption('--fixtures',
|
parser.addoption('--fixture',
|
||||||
action='store',
|
action='store',
|
||||||
default='default',
|
default='default',
|
||||||
help='the name of the environment for which you need fixture accounts.')
|
help='the name of the environment for which you need fixture accounts.')
|
||||||
@ -32,8 +32,8 @@ def fixture_data(pytestconfig):
|
|||||||
"""
|
"""
|
||||||
The fixture data items for the account under test
|
The fixture data items for the account under test
|
||||||
"""
|
"""
|
||||||
env = pytestconfig.getoption("env")
|
#env = pytestconfig.getoption("env")
|
||||||
return _read_config_section(fixtures, env)
|
return _read_config_section(fixtures, "env")
|
||||||
|
|
||||||
|
|
||||||
def _read_config_section(source, section):
|
def _read_config_section(source, section):
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
Feature: Browser Demo
|
Feature: Browser Demo
|
||||||
Scenario: Load test.io web page
|
Scenario: Load test.io web page with chrome
|
||||||
Given I have a chrome driver
|
Given I have a chrome driver
|
||||||
When I navigate to test.io
|
When I navigate to test.io
|
||||||
Then The page is displayed
|
Then The page is displayed
|
||||||
|
|
||||||
|
Scenario: Load test.io web page with firefox
|
||||||
|
Given I have a firefox driver
|
||||||
|
When I navigate to test.io
|
||||||
|
Then The page is displayed
|
@ -3,6 +3,11 @@ from behave import then, when, given
|
|||||||
from browserdriver import BrowserDriver
|
from browserdriver import BrowserDriver
|
||||||
|
|
||||||
|
|
||||||
|
@given('I have a firefox driver')
|
||||||
|
def step_impl(context):
|
||||||
|
context.driver = BrowserDriver.get("firefox")
|
||||||
|
|
||||||
|
|
||||||
@given('I have a chrome driver')
|
@given('I have a chrome driver')
|
||||||
def step_impl(context):
|
def step_impl(context):
|
||||||
context.driver = BrowserDriver.get("chrome")
|
context.driver = BrowserDriver.get("chrome")
|
||||||
@ -13,6 +18,7 @@ def step_impl(context):
|
|||||||
context.driver.get("https://test.io")
|
context.driver.get("https://test.io")
|
||||||
print(context.driver.title)
|
print(context.driver.title)
|
||||||
|
|
||||||
|
|
||||||
@then('The page is displayed')
|
@then('The page is displayed')
|
||||||
def step_impl(context):
|
def step_impl(context):
|
||||||
assert context.driver.title == "QA Testing as a Service | test IO"
|
assert context.driver.title == "QA Testing as a Service | test IO"
|
||||||
|
Loading…
Reference in New Issue
Block a user