Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I switch to redirected url using selenium web driver

I would like to know if it is possible to switch to redirected url using java selenium web driver.

I am doing automation for an app in facebook, but the developer of that app has used "Request dialog" facebook api feature which accepts "redirect_url" in java script.

How do I switch my web driver to that redirected page?

One solution for this is

String redirected_url = driver.getCurrentUrl();//This url is not matching with the one  showing in address bar.
driver.get(redirected_url);

Problem with the above is same page is loading again but now with redirected url showing in address bar and it is allowing me to do automation further

I need a solution something like which will use driver.switchTo().

Actually when I click on a button it is redirecting to another page (redirecting url is internal, we cant see this url in address bar but can fetch using driver.getCurrentUrl()). This redirecting url we can get using selenium web driver but there is no change in page source after redirect

Thanks in advance for your help.

like image 608
user2753523 Avatar asked Oct 18 '25 14:10

user2753523


1 Answers

I am not familiar with Facebook API but I guess driver.navigate().to(url); is what you are looking for.

like image 155
Petr Mensik Avatar answered Oct 21 '25 05:10

Petr Mensik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!