Home > Back-end >  How to find which element to use with Selenium Python?
How to find which element to use with Selenium Python?

Time:02-23

I'm trying to log in to this website but it's created with js, I think it is React which I have no experience.

This is an image of inspected code of the website that I try to log in.

enter image description here

I tried this...

email_field = browser.find_element_by_name('input_login_3kzbI')
email_field = browser.find_element_by_id('login-modal-email')

and then it should go this, but it fails on the line above...

email_field.send_keys("[email protected]")

CodePudding user response:

find_element_by_name checks against name attribute, and find_element_by_id checks against id attribute. There is no such attributes for the input element, so it failed.

Try this: browser.find_element_by_xpath('//input[@qa-id="login-modal-email"]')

  • Related