Skip to content

Commit 18b18f9

Browse files
authored
Merge pull request #1836 from seleniumbase/multithreading-improvements
Multithreading Improvements
2 parents ec5bb9c + 0188b1f commit 18b18f9

18 files changed

+211
-46
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ pytest my_first_test.py --pdb
499499
--edge # (Shortcut for "--browser=edge".)
500500
--firefox # (Shortcut for "--browser=firefox".)
501501
--safari # (Shortcut for "--browser=safari".)
502-
--cap-file=FILE # (The web browser's desired capabilities to use.)
503-
--cap-string=STRING # (The web browser's desired capabilities to use.)
504502
--settings-file=FILE # (Override default SeleniumBase settings.)
505503
--env=ENV # (Set the test env. Access with "self.env" in tests.)
506504
--account=STR # (Set account. Access with "self.account" in tests.)
@@ -513,11 +511,14 @@ pytest my_first_test.py --pdb
513511
--protocol=PROTOCOL # (The Selenium Grid protocol: http|https.)
514512
--server=SERVER # (The Selenium Grid server/IP used for tests.)
515513
--port=PORT # (The Selenium Grid port used by the test server.)
516-
--proxy=SERVER:PORT # (Connect to a proxy server:port for tests.)
517-
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use authenticated proxy server.)
518-
--proxy-bypass-list=STRING # (";"-separated hosts to bypass, Eg "*.foo.com")
514+
--cap-file=FILE # (The web browser's desired capabilities to use.)
515+
--cap-string=STRING # (The web browser's desired capabilities to use.)
516+
--proxy=SERVER:PORT # (Connect to a proxy server:port as tests are running)
517+
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use an authenticated proxy server)
518+
--proxy-bypass-list=STRING # (";"-separated hosts to bypass, Eg "*.foo.com")
519519
--proxy-pac-url=URL # (Connect to a proxy server using a PAC_URL.pac file.)
520520
--proxy-pac-url=USERNAME:PASSWORD@URL # (Authenticated proxy with PAC URL.)
521+
--multi-proxy # (Allow multiple authenticated proxies when multi-threaded.)
521522
--agent=STRING # (Modify the web browser's User-Agent string.)
522523
--mobile # (Use the mobile device emulator while running tests.)
523524
--metrics=STRING # (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)

examples/proxy_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_proxy(self):
1818
print("Skipping test for using Safari.")
1919
self.skip("Skipping test for using Safari.")
2020
settings.SKIP_JS_WAITS = True
21-
if not self.page_load_strategy == "none":
21+
if not self.page_load_strategy == "none" and not self.undetectable:
2222
# This page takes too long to load otherwise
2323
self.get_new_driver(page_load_strategy="none")
2424
self.open("https://ipinfo.io/")

examples/raw_parameter_script.py

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
sb.proxy_string = None
117117
sb.proxy_bypass_list = None
118118
sb.proxy_pac_url = None
119+
sb.multi_proxy = False
119120
sb.swiftshader = False
120121
sb.ad_block_on = False
121122
sb.highlights = None

examples/test_hack_search.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def test_hack_search(self):
1313
print("\n This test is not for Headless Mode.")
1414
self.skip('Do not use "--headless" with this test.')
1515
self.open("https://google.com/ncr")
16-
self.assert_element('input[title="Search"]')
16+
self.assert_element('[title="Search"]')
1717
self.sleep(0.5)
1818
self.set_attribute('[action="/search"]', "action", "//bing.com/search")
1919
self.set_attributes('[value="Google Search"]', "value", "Bing Search")
20-
self.type('input[title="Search"]', "GitHub SeleniumBase Docs Install")
20+
self.type('[title="Search"]', "GitHub SeleniumBase Docs Install")
2121
self.sleep(0.5)
2222
self.js_click('[value="Bing Search"]')
2323
self.highlight("h1.b_logo", loops=8)

help_docs/customizing_test_runs.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ pytest my_first_test.py --settings-file=custom_settings.py
105105
--edge # (Shortcut for "--browser=edge".)
106106
--firefox # (Shortcut for "--browser=firefox".)
107107
--safari # (Shortcut for "--browser=safari".)
108-
--cap-file=FILE # (The web browser's desired capabilities to use.)
109-
--cap-string=STRING # (The web browser's desired capabilities to use.)
110108
--settings-file=FILE # (Override default SeleniumBase settings.)
111109
--env=ENV # (Set the test env. Access with "self.env" in tests.)
112110
--account=STR # (Set account. Access with "self.account" in tests.)
@@ -119,11 +117,14 @@ pytest my_first_test.py --settings-file=custom_settings.py
119117
--protocol=PROTOCOL # (The Selenium Grid protocol: http|https.)
120118
--server=SERVER # (The Selenium Grid server/IP used for tests.)
121119
--port=PORT # (The Selenium Grid port used by the test server.)
122-
--proxy=SERVER:PORT # (Connect to a proxy server:port for tests.)
123-
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use authenticated proxy server.)
124-
--proxy-bypass-list=STRING # (";"-separated hosts to bypass, Eg "*.foo.com")
120+
--cap-file=FILE # (The web browser's desired capabilities to use.)
121+
--cap-string=STRING # (The web browser's desired capabilities to use.)
122+
--proxy=SERVER:PORT # (Connect to a proxy server:port as tests are running)
123+
--proxy=USERNAME:PASSWORD@SERVER:PORT # (Use an authenticated proxy server)
124+
--proxy-bypass-list=STRING # (";"-separated hosts to bypass, Eg "*.foo.com")
125125
--proxy-pac-url=URL # (Connect to a proxy server using a PAC_URL.pac file.)
126126
--proxy-pac-url=USERNAME:PASSWORD@URL # (Authenticated proxy with PAC URL.)
127+
--multi-proxy # (Allow multiple authenticated proxies when multi-threaded.)
127128
--agent=STRING # (Modify the web browser's User-Agent string.)
128129
--mobile # (Use the mobile device emulator while running tests.)
129130
--metrics=STRING # (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)

mkdocs_build/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ click==8.1.3
1414
ghp-import==2.1.0
1515
readme-renderer==37.3
1616
pymdown-extensions==9.11
17-
importlib-metadata==6.2.0
17+
importlib-metadata==6.3.0
1818
pipdeptree==2.7.0
1919
bleach==6.0.0
2020
lunr==0.6.2

requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ soupsieve==2.4;python_version>="3.7"
7979
beautifulsoup4==4.12.2
8080
cryptography==36.0.2;python_version<"3.7"
8181
cryptography==40.0.1;python_version>="3.7"
82-
pygments==2.14.0
82+
pygments==2.14.0;python_version<"3.7"
83+
pygments==2.15.0;python_version>="3.7"
8384
pyreadline3==3.4.1;platform_system=="Windows"
8485
tabcompleter==1.1.0
8586
pdbp==1.2.8
8687
colorama==0.4.5;python_version<"3.7"
8788
colorama==0.4.6;python_version>="3.7"
8889
exceptiongroup==1.1.1;python_version>="3.7"
90+
future-breakpoint==2.0.0;python_version<"3.7"
8991
importlib-metadata==4.2.0;python_version<"3.8"
9092
pycparser==2.21
9193
pyotp==2.7.0;python_version<"3.7"

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.13.22"
2+
__version__ = "4.13.23"

seleniumbase/behave/behave_sb.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
-D port=PORT (The Selenium Grid port used by the test server.)
2626
-D cap-file=FILE (The web browser's desired capabilities to use.)
2727
-D cap-string=STRING (The web browser's desired capabilities to use.)
28-
-D proxy=SERVER:PORT (Connect to a proxy server:port for tests.)
29-
-D proxy=USERNAME:PASSWORD@SERVER:PORT (Use authenticated proxy server.)
28+
-D proxy=SERVER:PORT (Connect to a proxy server:port as tests are running)
29+
-D proxy=USERNAME:PASSWORD@SERVER:PORT (Use an authenticated proxy server)
3030
-D proxy-bypass-list=STRING (";"-separated hosts to bypass, Eg "*.foo.com")
3131
-D proxy-pac-url=URL (Connect to a proxy server using a PAC_URL.pac file.)
3232
-D proxy-pac-url=USERNAME:PASSWORD@URL (Authenticated proxy with PAC URL.)
33+
-D multi-proxy (Allow multiple authenticated proxies when multi-threaded.)
3334
-D agent=STRING (Modify the web browser's User-Agent string.)
3435
-D mobile (Use the mobile device emulator while running tests.)
3536
-D metrics=STRING (Set mobile metrics: "CSSWidth,CSSHeight,PixelRatio".)
@@ -223,6 +224,7 @@ def get_configured_sb(context):
223224
sb.proxy_string = None
224225
sb.proxy_bypass_list = None
225226
sb.proxy_pac_url = None
227+
sb.multi_proxy = False
226228
sb.enable_3d_apis = False
227229
sb.swiftshader = False
228230
sb.ad_block_on = False
@@ -746,6 +748,10 @@ def get_configured_sb(context):
746748
proxy_pac_url = sb.proxy_pac_url # revert to default
747749
sb.proxy_pac_url = proxy_pac_url
748750
continue
751+
# Handle: -D multi-proxy / multi_proxy
752+
if low_key in ["multi-proxy", "multi_proxy"]:
753+
sb.multi_proxy = True
754+
continue
749755
# Handle: -D enable-3d-apis / enable_3d_apis
750756
if low_key in ["enable-3d-apis", "enable_3d_apis"]:
751757
sb.enable_3d_apis = True
@@ -1121,7 +1127,8 @@ def _perform_behave_unconfigure_():
11211127
from seleniumbase.core import log_helper
11221128
from seleniumbase.core import proxy_helper
11231129

1124-
proxy_helper.remove_proxy_zip_if_present()
1130+
if hasattr(sb_config, "multi_proxy") and not sb_config.multi_proxy:
1131+
proxy_helper.remove_proxy_zip_if_present()
11251132
if hasattr(sb_config, "reuse_session") and sb_config.reuse_session:
11261133
# Close the shared browser session
11271134
if sb_config.shared_driver:

0 commit comments

Comments
 (0)