Reputation: 1
http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert
Above is the website, cant click on that "try it", no locator techniques working ?
driver.get("http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert");
driver.findElement(By.xpath(".//button[@onclick='myFunction()']")).click();
Upvotes: 0
Views: 59
Reputation: 7708
Your element is iniFrame
so first you need to switch into frame
and then have to perform your actions.
Use this :
driver.switchTo().frame(driver.findElement(By.id("iframeResult")));
driver.findElement(By.xpath(".//button[@onclick='myFunction()']")).click();
Use following code to switchback from the iframe
and do your actions other then this frame's element:
driver.switchTo().defaultContent();
Upvotes: 1