I am new to StackOverflow so I will try my best to describe the problem.
I am at the page of https://www.google.com/ and you know there is the search button. I typed my query and clicked the search button using selenium. So it will take some time. I want to get the URL after finished the search. That exactly means how to get the URL of a page after it got loaded. Because let me explain...
- A page having a captcha. I have to fill and click on submit
- If the captcha is right then it will open another URL in the URL bar.
- But if the captcha is wrong then it will stay on the same URL
- So I wanted to know the captcha is worked or not
- If the captcha worked then it definitely goes to the next URL.
I tried:
try:
WebDriverWait(self.driver, 2).until(EC.url_changes('https://www.mystaticurl.com/aftercaptchafilled'))
print('Captcha Accepted')
except TimeoutException:
print('[Captcha Error : Solving captcha code]')
self.Fill_captcha_function()
But it is not working. It still shows captcha is filled Anyone, please?
Thanks in Advance
CodePudding user response:
After your action, please get the current url using following method,
driver.current_url
CodePudding user response:
Adding onto what Jayanth said, I personally used this method.
current = driver.current_url
failed = "https://www.google.com"
if current == failed:
print("Still same url!")
if current != failed:
print("New url!")
You could also do
driver.get("google.com")
old = driver.current_url
"captcha code here"
new = driver.current_url
if new == old:
print("did not work :(")
if new != old:
print("YAY it worked :)")