33from selenium import webdriver
44from selenium .common .exceptions import TimeoutException
55from selenium .webdriver .common .by import By
6- from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
76from selenium .webdriver .firefox .options import Options
87from selenium .webdriver .support import expected_conditions as EC
98from selenium .webdriver .support .ui import WebDriverWait
@@ -80,15 +79,15 @@ def get_firefox_webdriver(cls):
8079
8180 @classmethod
8281 def get_chrome_webdriver (cls ):
83- chrome_options = webdriver .ChromeOptions ()
84- chrome_options .page_load_strategy = 'eager'
82+ options = webdriver .ChromeOptions ()
83+ options .page_load_strategy = 'eager'
8584 if os .environ .get ('SELENIUM_HEADLESS' , False ):
86- chrome_options .add_argument ('--headless' )
85+ options .add_argument ('--headless' )
8786 CHROME_BIN = os .environ .get ('CHROME_BIN' , None )
8887 if CHROME_BIN :
89- chrome_options .binary_location = CHROME_BIN
90- chrome_options .add_argument ('--window-size=1366,768' )
91- chrome_options .add_argument ('--ignore-certificate-errors' )
88+ options .binary_location = CHROME_BIN
89+ options .add_argument ('--window-size=1366,768' )
90+ options .add_argument ('--ignore-certificate-errors' )
9291 # When running Selenium tests with the "--parallel" flag,
9392 # each TestCase class requires its own browser instance.
9493 # If the same "remote-debugging-port" is used for all
@@ -97,16 +96,11 @@ def get_chrome_webdriver(cls):
9796 # debugging ports for each TestCase. To accomplish this,
9897 # we can leverage the randomized live test server port to
9998 # generate a unique port for each browser instance.
100- chrome_options .add_argument (
101- f'--remote-debugging-port={ cls .server_thread .port + 100 } '
99+ options .add_argument (f'--remote-debugging-port={ cls .server_thread .port + 100 } ' )
100+ options .set_capability ('goog:loggingPrefs' , {'browser' : 'ALL' })
101+ return webdriver .Chrome (
102+ options = options ,
102103 )
103- capabilities = DesiredCapabilities .CHROME
104- capabilities ['goog:loggingPrefs' ] = {'browser' : 'ALL' }
105- chrome_options .set_capability ('cloud:options' , capabilities )
106- web_driver = webdriver .Chrome (
107- options = chrome_options ,
108- )
109- return web_driver
110104
111105 @classmethod
112106 def tearDownClass (cls ):
0 commit comments