Balaji
Balaji

Reputation: 39

Selenium-WebDriver: Open links in the same IE window

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.

Upvotes: 1

Views: 1843

Answers (1)

Rupesh Shinde
Rupesh Shinde

Reputation: 1956

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.

Upvotes: 1

Related Questions