问题
I am using selenium Java. I need to open new tab and open URL in the newly opened tab. I am try to using getWindowHandles, its working fine in google chrome, but the same code is not working for Internet Explorer. Please suggest the proper solution for this. Here is the code I have used.
WebDriver=new InternetExplorerDriver();
driver.get("https://google/com");
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL+"t");// Open new tab
driver.switchTo().window(driver.getWindowHandles().iterator().next());
driver.get("http://msn.com");
I also tried following code, but not working.
ArrayList<String> tabs= new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs.get(index));
Note: The same code working fine with google chrome, not working in IE only. IE version:IE10
来源:https://stackoverflow.com/questions/40014966/selenium-switching-to-new-tab-in-ie