Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
105 views
in Technique[技术] by (71.8m points)

python - How can I located element in selenium using the following element?

I am trying to find the following element in seleniumenter image description here

It is a user name input field and I use: loginLink = driver.find_element(By.name, "loginEmail" but keep getting "no such element" message.

question from:https://stackoverflow.com/questions/65546703/how-can-i-located-element-in-selenium-using-the-following-element

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
//input[@ng-reflect-name='loginEmail']

Use xpath or CSS , you can find by name only if the attribute key is 'name'

Eg 'name=loginEmail'

driver.find_element_by_xpath("//input[@ng-reflect-name='loginEmail']")

driver.find_element_by_css_selector("input[ng-reflect-name='loginEmail']")

you can use xpath and css for any attribute as

xpath: //tagname[@attriubute='value'] css: tagname[attriubute='value']


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...