gallly
gallly

Reputation: 1211

why is selenium webdriver not finding my element

https://www.mykplan.com/participantsecure_net/TermsAndConditions.aspx I am doing find by id/xpath/name and they all fail for the accept button. Here is my latest effort

driver.find_element_by_xpath('//*[@id="Accept"]').click()

copied straight from chrome web tool

Upvotes: 1

Views: 1166

Answers (1)

Marcin Kowalczyk
Marcin Kowalczyk

Reputation: 649

The button is located inside a frame. Given xpath is correct only inside a frame. I tested xpaths in chrome console and this is what I got:

In case of main page (https://www.mykplan.com/participantsecure_net/TermsAndConditions.aspx) xpath couldn't be located:

$x('//*[@id="Accept"]');
[]

In case of frame contents only (https://www.mykplan.com/participantsecure_net/TermsAndConditionsBottom.aspx) xpath could be found:

$x('//*[@id="Accept"]');
[<input type=​"submit" name=​"Accept" value=​"I agree" id=​"Accept">​]

In selenium, I guess you need to switch to a frame before looking for xpath. I think that web driver function

driver.switch_to_frame("frameName") 

should help. In your case, frame with buttons is called "bottomFrame".

Upvotes: 2

Related Questions