Bunny
Bunny

Reputation: 147

How to look for html element with selenium and VBA within a frame

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.

enter image description here

Upvotes: 0

Views: 1130

Answers (2)

Zakaria Acharki
Zakaria Acharki

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

undetected Selenium
undetected Selenium

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 :

Pseudo Code :

//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

Related Questions