Selenium switching to new Tab in IE

风流意气都作罢 提交于 2020-02-07 08:38:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!