Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

python 3.x - Selenium - Finding element based on ember

I am working with selenium in python 3.6 on the chrome browser. I have programmed it to the point where I can access the website I want but I am struggling to find the text box element I am searching for. When I inspect the element it has this code.

<input placeholder="" id="ember32" class="ssRegistrationField ssEmailTextboxField ember-text-field ember-view" type="email">

But when I try and use the given ID, it does not work and says that it cannot be found. Here is my code (Without the text I wish to insert of the website URL):

from selenium import webdriver

browser = webdriver.Chrome('chromedriver.exe')

browser.get('')

email = browser.find_element_by_id("ember34")
email.send_keys('')

I have just started using Selenium today and any help figuring out what is wrong would be very appreciated.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

WebDriverWait(browser,5).until(
              EC.presence_of_element_located((By.ID,'ember32')))

browser.find_element(By.ID,'ember32').send_keys('Your_Email')

The problem was the DOM has ember32 and your program is looking for ember34, Basic Typeo.

The code above will add an implicate wait for 5 seconds, search for ember32, and then time out if it cant find it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...