How to Open a URL in a new tab in IE using selenium webdriver

67 views
Skip to first unread message

Pragnya Sahoo

unread,
Jun 14, 2016, 7:16:46 AM6/14/16
to Selenium Users
I want to open a new tab in IE and then open a URL in that new tab and do some operation there and then close that tab.

So, I used the below code and it is working fine with firefox

driver.get("http://google.com");

driver.findElement(By.tagName("body")).sendKeys(Keys.CONTROL,"t"); // opens a new tab

driver.get("http://facebook.com");

driver.findElement(By.tagName("body")).sendKeys(Keys.CONTROL,"w"); // closes that new tab



But the above code doesn't work with IE.
What it does is that it opens a new tab, but after that it opens the 2nd url in the parent tab while the new tab is in focus. And at the end it closes the new tab.

So, please help me in finding a solution for it so that the 2nd url opens up in a new tab in IE.
Reply all
Reply to author
Forward
0 new messages