RE: Need to Locate JavaScript Link

a Javascript link appear in a child pop up window when i Click on an image in Parent Window.

I need to locate this webElement. Here is my code.

driver.findElement(By.xpath(“html/body/form/div[2]/a”)).click();
JavascriptExecutor executor = (JavascriptExecutor)driver
executor.executeScript(passBack(v[1], v2[1]).click()”;

The link in a new popup window which i am not able to locate.

rehanshahid Train Asked on November 2, 2015 in Selenium WebDriver.
Add Comment
3 Answers

executor.executeScript(passBack(v[1], v2[1]).click()”);

this is a wrong statement. The reason is that javascript:passBack(v[1], v2[1] is a function call where v[1], v2[1] will have runtime values.

I would suggest you can find the element using findElementByLinkText method. You also mentioned its a link in a new window. I am wondering if the new window is an alert. If its an alert you will have to switch to alert before trying to access the element.

http://www.toolsqa.com/selenium-webdriver/handling-of-alerts-javascript-alerts-and-popup-boxes/

Virender

Professor Answered on November 4, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.