4

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.

2
  • 1
    If its a redirect, the new URL will appear in the browser address bar. You are describing forwards, not redirects. Commented Nov 3, 2013 at 19:42
  • is the question - how to access the dialog that opens up ? Commented Nov 4, 2013 at 5:37

1 Answer 1

7

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.