I am working on a project which includes clicking on a link and that should open in a new tab using webdriver, the problem is
The supposed link is contained in iFrame, so
shift+click
isn't workingprivate void openInNewTabAndSwitch(WebElement linkElement) { // logic of opening in new tab goes here... Actions newTab = new Actions(driver); newTab.keyDown(Keys.SHIFT).click(linkElement).keyUp(Keys.SHIFT).build().perform(); Set<String> windowSet = driver.getWindowHandles(); driver.switchTo().window((String) windowSet.toArray()[1]); }
I cannot find the
href
attribute since some javascript function is opening it using someonClick()
<a onclick="javascript:LinkOccam (this, 'opportunity');">Mednomics Proposition</a>
Problem:- It simply opens the required page in same tab.
Now, I cannot find anything related to this, please help..!
Other related info I am using windows 7, Java 8, ChromeDriver