6

I'm using Selenium WebDriver (Java) and am trying to change the URL after WebDriver has logged into a page.

Is there a way to either:

  1. Change the URL of the current window, or
  2. Open a new tab and go to another page.

Thanks!

1 Answer 1

15

You didn't share any code so i don't know how is your approach about it, I only share my knowledge about this subject.

1) For your first question i think you know how to open a new page with selenium web driver maybe you can use some wait method and then invoke the driver again.

    //open browser
    driver = new FirefoxDriver();

    //login
    driver.get("https://www.google.com/");

    //set implicit wait
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

    //Then invoke method again for your second request(I am not try this code maybe you need to create new driver object)
    driver.get("https://www.stackoverflow.com");

2) For your second question this link help you.

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

2 Comments

Hmm... it must be something w/ the site that I'm testing because I can't seem to open the second link using driver.get() but if I try your example, it works.
Actually, it looks like for my situation, I did need to create a new WebDriver instance.

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.