RE: I’m automating script using java using selenium webdriver. But i’m getting stuck on switch to new tab and pass url in new tab as well using chrome browser.Can you provide be solution for that.

Add Comment
2 Answers

Hi Surabhi,

This is an example code. You can customize it according to your use.

// Initialize driver
WebDriver driver = new FirefoxDriver();

//Maximize browser window

//Go to URL

//Set timeout
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

// Open new tab  – May be you are stuck here
driver.findElement(By.cssSelector(“body”)).sendKeys(Keys.CONTROL + “t”);

//Go to URL

//Set new tab timeout
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

// Do some operation

Vishal S

Doctor Answered on May 25, 2016.
WebDriver driver = new ChromeDriver(); // for chrome driver
on May 25, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.