selenium - Replace a portion of url in python -
i need replace portion of following url in selenium webdriver+python:
https://ve-215:8443/cloudweb/dropbox_authorized?oauth_token=l8eyufg8nux3tuhm&uid=69768040
i need replace ve-215
ip address 192.168.24.53
i tried using replace
doesnt work.
following code using:
current_url=driver.current_url print(current_url) #prints url of current window. current_url.replace("ve-215", "192.168.53.116") print(current_url) #print url replaced string driver.get(current_url) #open window replaced url
can me wrong above code?
replace
method not modify string (strings immutable in python) returns new string. try
current_url = current_url.replace("ve-215", "192.168.53.116")
that being said, advised use urlparse
module (urllib.parse
in python 3) parsing , reconstructing urls.
Comments
Post a Comment