Skip to content

Commit aee8e9c

Browse files
authored
[chores] Randomize remote-debugging-port for Selenium tests openwisp#340
Related to openwisp#340
1 parent b2dcb08 commit aee8e9c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

openwisp_utils/test_selenium_mixins.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ def setUpClass(cls):
2323
chrome_options.add_argument('--headless')
2424
chrome_options.add_argument('--window-size=1366,768')
2525
chrome_options.add_argument('--ignore-certificate-errors')
26-
chrome_options.add_argument('--remote-debugging-port=9222')
26+
# When running Selenium tests with the "--parallel" flag,
27+
# each TestCase class requires its own browser instance.
28+
# If the same "remote-debugging-port" is used for all
29+
# TestCase classes, it leads to failed test cases.
30+
# Therefore, it is necessary to utilize different remote
31+
# debugging ports for each TestCase. To accomplish this,
32+
# we can leverage the randomized live test server port to
33+
# generate a unique port for each browser instance.
34+
chrome_options.add_argument(
35+
f'--remote-debugging-port={cls.server_thread.port + 100}'
36+
)
2737
capabilities = DesiredCapabilities.CHROME
2838
capabilities['goog:loggingPrefs'] = {'browser': 'ALL'}
2939
chrome_options.set_capability('cloud:options', capabilities)

0 commit comments

Comments
 (0)