|
10 | 10 | from selenium.webdriver.firefox.options import Options as FirefoxOptions |
11 | 11 | from selenium.webdriver.edge.options import Options as EdgeOptions |
12 | 12 | from selenium.webdriver.chrome.options import Options as ChromeOptions |
| 13 | +from selenium.webdriver.remote.client_config import ClientConfig |
13 | 14 |
|
14 | 15 | SELENIUM_GRID_PROTOCOL = os.environ.get('SELENIUM_GRID_PROTOCOL', 'http') |
15 | 16 | SELENIUM_GRID_HOST = os.environ.get('SELENIUM_GRID_HOST', 'localhost') |
16 | 17 | SELENIUM_GRID_PORT = os.environ.get('SELENIUM_GRID_PORT', '4444') |
17 | | -SELENIUM_GRID_USERNAME = os.environ.get('SELENIUM_GRID_USERNAME', '') |
18 | | -SELENIUM_GRID_PASSWORD = os.environ.get('SELENIUM_GRID_PASSWORD', '') |
| 18 | +SELENIUM_GRID_USERNAME = os.environ.get('SELENIUM_GRID_USERNAME', None) |
| 19 | +SELENIUM_GRID_PASSWORD = os.environ.get('SELENIUM_GRID_PASSWORD', None) |
19 | 20 | SELENIUM_GRID_TEST_HEADLESS = os.environ.get('SELENIUM_GRID_TEST_HEADLESS', 'false').lower() == 'true' |
20 | 21 | SELENIUM_ENABLE_MANAGED_DOWNLOADS = os.environ.get('SELENIUM_ENABLE_MANAGED_DOWNLOADS', 'true').lower() == 'true' |
21 | 22 | WEB_DRIVER_WAIT_TIMEOUT = int(os.environ.get('WEB_DRIVER_WAIT_TIMEOUT', 60)) |
|
29 | 30 | TEST_ADD_CAPS_RECORD_VIDEO = os.environ.get('TEST_ADD_CAPS_RECORD_VIDEO', 'true').lower() == 'true' |
30 | 31 | TEST_CUSTOM_SPECIFIC_NAME = os.environ.get('TEST_CUSTOM_SPECIFIC_NAME', 'false').lower() == 'true' |
31 | 32 |
|
32 | | -if SELENIUM_GRID_USERNAME and SELENIUM_GRID_PASSWORD: |
33 | | - SELENIUM_GRID_HOST = f"{SELENIUM_GRID_USERNAME}:{SELENIUM_GRID_PASSWORD}@{SELENIUM_GRID_HOST}" |
| 33 | +SELENIUM_GRID_URL = "%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) |
| 34 | +CLIENT_CONFIG = ClientConfig( |
| 35 | + remote_server_addr=SELENIUM_GRID_URL, |
| 36 | + keep_alive=False, |
| 37 | + timeout=3600, username=SELENIUM_GRID_USERNAME, |
| 38 | + password=SELENIUM_GRID_PASSWORD |
| 39 | +) |
34 | 40 |
|
35 | 41 | if TEST_NODE_RELAY == 'Android': |
36 | 42 | time.sleep(90) |
@@ -159,7 +165,8 @@ def setUp(self): |
159 | 165 | start_time = time.time() |
160 | 166 | self.driver = webdriver.Remote( |
161 | 167 | options=options, |
162 | | - command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) |
| 168 | + command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT), |
| 169 | + client_config=CLIENT_CONFIG |
163 | 170 | ) |
164 | 171 | end_time = time.time() |
165 | 172 | print(f"Begin: {self._testMethodName} ({self.__class__.__name__}) WebDriver initialization completed in {end_time - start_time} (s)") |
@@ -187,7 +194,8 @@ def setUp(self): |
187 | 194 | start_time = time.time() |
188 | 195 | self.driver = webdriver.Remote( |
189 | 196 | options=options, |
190 | | - command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) |
| 197 | + command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT), |
| 198 | + client_config=CLIENT_CONFIG |
191 | 199 | ) |
192 | 200 | end_time = time.time() |
193 | 201 | print(f"Begin: {self._testMethodName} ({self.__class__.__name__}) WebDriver initialization completed in {end_time - start_time} (s)") |
@@ -220,7 +228,8 @@ def setUp(self): |
220 | 228 | start_time = time.time() |
221 | 229 | self.driver = webdriver.Remote( |
222 | 230 | options=options, |
223 | | - command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT) |
| 231 | + command_executor="%s://%s:%s" % (SELENIUM_GRID_PROTOCOL,SELENIUM_GRID_HOST,SELENIUM_GRID_PORT), |
| 232 | + client_config=CLIENT_CONFIG |
224 | 233 | ) |
225 | 234 | end_time = time.time() |
226 | 235 | print(f"Begin: {self._testMethodName} ({self.__class__.__name__}) WebDriver initialization completed in {end_time - start_time} (s)") |
|
0 commit comments