Reputation: 147
I am trying to use selenium web driver with the driver.FindElementById"retrieve_button" in an html page, but the command could not find the element and keep giving me error. I have attached the html code in the image and the element I'm trying to find is the input element at the end of the code in the image.
Any help would be very much appreciated.
Upvotes: 0
Views: 1130
Reputation: 67495
Try to switch using the function switchToFrame
, like :
sel.switchToFrame "Login" // 'Login' is the frame 'name' or 'id'.
//Then get your element
sel.findElementById("retrieve_button")
Upvotes: 1
Reputation: 193058
You are seeing the error with driver.FindElementById"retrieve_button"
as the WebElement
is within an <iframe>
which contains the attribute src
with a value set to /index.cgi?top<text_not_clear_in_snapshot>
.
You need to first switch to the <iframe>
first and then find the WebElement
as follows :
//SwitchTo the intended frame
driver.switchToFrame(driver.FindElement(By.XPath("//iframe[contains(@src,'/index.cgi?top<text_not_clear_in_snapshot>')]")))
//find the element now
driver.FindElementByXPath("//input[@name='retrieve_button']")
Note : Ignore the
<frameset>
tags. They have null effect.
Upvotes: 0