11"""
22Environment for Behave Testing
33"""
4+
45from os import getenv
56from selenium import webdriver
67
7- WAIT_SECONDS = int (getenv (' WAIT_SECONDS' , '30' ))
8- BASE_URL = getenv (' BASE_URL' , ' http://localhost:8080' )
9- DRIVER = getenv (' DRIVER' , ' firefox' ).lower ()
8+ WAIT_SECONDS = int (getenv (" WAIT_SECONDS" , "30" ))
9+ BASE_URL = getenv (" BASE_URL" , " http://localhost:8080" )
10+ DRIVER = getenv (" DRIVER" , " firefox" ).lower ()
1011
1112
1213def before_all (context ):
13- """ Executed once before all tests """
14+ """Executed once before all tests"""
1415 context .base_url = BASE_URL
1516 context .wait_seconds = WAIT_SECONDS
1617 # Select either Chrome or Firefox
17- if ' firefox' in DRIVER :
18+ if " firefox" in DRIVER :
1819 context .driver = get_firefox ()
1920 else :
2021 context .driver = get_chrome ()
@@ -24,15 +25,18 @@ def before_all(context):
2425
2526
2627def after_all (context ):
27- """ Executed after all tests """
28+ """Executed after all tests"""
2829 context .driver .quit ()
2930
31+
3032######################################################################
3133# Utility functions to create web drivers
3234######################################################################
3335
36+
3437def get_chrome ():
3538 """Creates a headless Chrome driver"""
39+ print ("Running Behave using the Chrome driver...\n " )
3640 options = webdriver .ChromeOptions ()
3741 options .add_argument ("--no-sandbox" )
3842 options .add_argument ("--disable-dev-shm-usage" )
@@ -42,7 +46,9 @@ def get_chrome():
4246
4347def get_firefox ():
4448 """Creates a headless Firefox driver"""
49+ print ("Running Behave using the Firefox driver...\n " )
4550 options = webdriver .FirefoxOptions ()
51+ options .add_argument ("--no-sandbox" )
52+ options .add_argument ("--disable-dev-shm-usage" )
4653 options .add_argument ("--headless" )
47- return webdriver .Firefox (options = options )
48-
54+ return webdriver .Firefox (options = options )
0 commit comments