WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("URL");
String newWindow = driver.getWindowHandle();
driver.findElement(By.cssSelector(“body”)).sendKeys(Keys.CONTROL+”t”);
driver.get("Second URL");
//Perform whatever actions you want done on the secondary tab, let’s pretend we’re logging in somewhere
driver.findElementById(“ID”).sendKeys(“username”);
driver.findElementById(“ID”).sendKeys(“password”);
driver.findElementById(“submit”).click();
driver.switchTo().window(mainWindow);
//Perform whatever actions you want done on the main tab, we’ll click a button
driver.findElementById(“button”).click();
# Close current tab
driver.findElement(By.cssSelector(“body”)).sendKeys(Keys.CONTROL + 'w');
driver.close();
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
this is a good instruct ion, so it can be used to switch and automate different web pages
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit