top of page
Search

How to Open second URL in new Tab of a Browser Using Selenium WebDriver with Java.

  • qatestingthreesixt
  • Dec 1, 2021
  • 1 min read

First open url in First Tab and open second tab by Pressing “Control+t” from keyboard.


Now disable the first Tab and insert second url in second Tab.


You can use Following code:


CODE:

public class basics {

public static void main(String[] args) throws AWTException, InterruptedException {

// TODO Auto-generated method stub

WebDriver driver;

System.setProperty(“webdriver.chrome.driver”, “D: \\Tools\\ BrowserDriver\\ chromedriver.exe”);

driver = new ChromeDriver();

driver.get(“http://www.google.com/&#8221);

driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

System.out.println(driver.getTitle());

Thread.sleep(5000);

driver.findElement(By.cssSelector(“body”)).sendKeys(Keys.CONTROL + ”t”);

ChromeOptions options = new ChromeOptions();

options.addArguments(“–disable - extensions”);

driver = new ChromeDriver(options); driver.manage().window().maximize();

driver.get(“http://www.yahoo.com/&#8221);

System.out.println(driver.getTitle());

}

}


 
 
 

Recent Posts

See All

Comments


Contact Us

PR World Trade Center, 108, near bus stand, Jalandhar, Punjab 144001

Phone or Whatsapp

+91-7652933997

     

bottom of page