Skip to content

Commit fdca9e4

Browse files
committed
Improve arg-parsing for Selenium Grid usage
1 parent 3ddc997 commit fdca9e4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,29 @@ def get_remote_driver(
877877
device_pixel_ratio,
878878
):
879879
downloads_path = download_helper.get_downloads_folder()
880-
address = "%s://%s:%s/wd/hub" % (protocol, servername, port)
880+
if servername.startswith("https://"):
881+
protocol = "https"
882+
servername = servername.split("https://")[1]
883+
elif "://" in servername:
884+
servername = servername.split("://")[1]
885+
server_with_port = ""
886+
if ":" not in servername:
887+
col_port = ":" + str(port)
888+
first_slash = servername.find("/")
889+
if first_slash != -1:
890+
server_with_port = (
891+
servername[:first_slash] + col_port + servername[first_slash:]
892+
)
893+
else:
894+
server_with_port = servername + col_port
895+
else:
896+
server_with_port = servername
897+
address = "%s://%s" % (protocol, server_with_port)
898+
if not address.endswith("/wd/hub"):
899+
if address.endswith("/"):
900+
address += "wd/hub"
901+
else:
902+
address += "/wd/hub"
881903
desired_caps = {}
882904
extra_caps = {}
883905
if cap_file:

0 commit comments

Comments
 (0)