1

I am trying to emulate clicking in my application using Selenium Webdriver and IE 8. I am trying to open a link in the same window so that the browser session and proxy settings are preserved.

Could someone suggest a way to do this with Selenium on IE?

Thanks.

Balaji
  • 39
  • 4

1 Answers1

1

If you want to manually open the Link in New Tab you can achieve this by performing Context Click on the Link and selecting 'Open in new Tab' option. Below is the implementation in Selenium web-driver with Java binding.

Actions newTab= new Actions(driver);
WebElement link = driver.findElement(By.xpath("//xpath of the element"));

//Open the link in new window
newTab.contextClick(link).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();

Web-driver handles new tab in the same way to that of new window. You will have to switch to new open tab by its window name.

driver.switchTo().window(windowName);

You can keep track of window-names which will help you to easily navigate between tabs.

Rupesh Shinde
  • 1,933
  • 12
  • 22
  • Rupesh, thanks for your reply. I think WebDriver does not support opening links in new tabs currently. If you know the url there are some workarounds using which a new tab can be opened - [WebDriver open new tab](http://stackoverflow.com/questions/6421988/webdriver-open-new-tab). But you cant do it with a click() or contextClick(). The above code opens a new window in IE 8 for me. Does it work for you? – Balaji Dec 18 '14 at 18:11