set the driver to headless, and add different tests for chrome and firefox

This commit is contained in:
Greg Gauthier 2020-10-10 19:04:35 +01:00
parent 77dc32f142
commit fc4cd7107c
5 changed files with 20 additions and 7 deletions

View File

@ -3,10 +3,10 @@ default_format = pretty
show_skipped = false
show_timings = true
stdout_capture = yes
logging-level=ERROR
logging-level = ERROR
[behave.userdata]
browser=chrome
browser = chrome
headless = True
name = gmgauthier@protonmail.com
platform = OSX

View File

@ -22,6 +22,7 @@ class BrowserDriver:
def chrome():
options = webdriver.ChromeOptions()
options.headless = True
options.add_argument('--ignore-certificate-errors')
return webdriver.Chrome(ChromeDriverManager().install(), options=options)
@ -29,6 +30,7 @@ def chrome():
def firefox():
options = webdriver.FirefoxOptions()
options.accept_insecure_certs = True
options.headless = True
gecko_driver = GeckoDriverManager().install()
return webdriver.Firefox(executable_path=gecko_driver, firefox_options=options)

View File

@ -12,7 +12,7 @@ def pytest_addoption(parser):
action='store',
default='staging',
help='the name of the environment for which you need properties.')
parser.addoption('--fixtures',
parser.addoption('--fixture',
action='store',
default='default',
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
"""
env = pytestconfig.getoption("env")
return _read_config_section(fixtures, env)
#env = pytestconfig.getoption("env")
return _read_config_section(fixtures, "env")
def _read_config_section(source, section):

View File

@ -1,5 +1,10 @@
Feature: Browser Demo
Scenario: Load test.io web page
Scenario: Load test.io web page with chrome
Given I have a chrome driver
When I navigate to test.io
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

View File

@ -3,6 +3,11 @@ from behave import then, when, given
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')
def step_impl(context):
context.driver = BrowserDriver.get("chrome")
@ -13,6 +18,7 @@ def step_impl(context):
context.driver.get("https://test.io")
print(context.driver.title)
@then('The page is displayed')
def step_impl(context):
assert context.driver.title == "QA Testing as a Service | test IO"