Selenium chrome opens the link on the new tab, seleniumchrome
Currently, chrome is the most stable browser for implementing webdriver. How can I use webdriver to open multiple tabs and links? What I can find everywhere is usually how to open tabs.
It is easy to open a tab. The shortcut key for chrome to open a tab is ctrl + t. You can just input the ctrl + t button event. There are many implementation methods:
1:
Actions actionOpenLinkInNewTab = new Actions (driver );
ActionOpenLinkInNewTab. keyDown (Keys. CONTROL). sendKeys ("t"). keyUp (Keys. CONTROL). perform ();
2:
Driver.findElement(By.css Selector ("body"). sendKeys (Keys. CONTROL + "t ");
Open all the code of the new link on the new tab (Google ):
String baseUrl = "http://www.google.co.uk /";
Driver. get (baseUrl );
Driver.findElement(By.css Selector ("body"). sendKeys (Keys. CONTROL + "t ");
ArrayList <String> tabs = new ArrayList <String> (driver. getWindowHandles ());
Driver. switchTo (). window (tabs. get (1); // switches to new tab
Driver. get ("https://www.facebook.com ");
Driver. switchTo (). window (tabs. get (0); // switch back to main screen
Driver. get ("https://www.news.google.com ");
Url: http://equalxx.iteye.com/blog/2291520