Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98827

Delete some text from current URL using selenium? [duplicate]

$
0
0

I have an url, let's say it is:

website.com/sometext/someothertext/deletetext

How do I delete deletetext? Then add some other text e.g: 123456? Preferably using selenium. I'm only trying to delete the text after the 3rd / I don't want to delete any text before that.

So far I've just got the current url (not including all the other code that doesn't matter here)

current_url = driver.current_url

I found the solution:

current_url = driver.current_url
new_url = current_url.replace("deletetext", "123456")
driver.get(new_url)

Viewing all articles
Browse latest Browse all 98827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>