5

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!

FilmiHero
  • 2,306
  • 7
  • 31
  • 46

1 Answers1

13

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.

erhun
  • 3,549
  • 2
  • 35
  • 44
  • 1
    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. – FilmiHero Jan 17 '13 at 21:21
  • Actually, it looks like for my situation, I _did_ need to create a new WebDriver instance. – FilmiHero Jan 17 '13 at 21:23