什么是正确的代码来查找电子邮件输入 https://accounts.google.com/ServiceLogin?
https://accounts.google.com/ServiceLogin?
的HTML是 <input id="Email" class="" type="email" spellcheck="false" value="" placeholder="Email" name="Email"></input>
<input id="Email" class="" type="email" spellcheck="false" value="" placeholder="Email" name="Email"></input>
我引用的是https://pypi.python.org/pypi/selenium
from selenium import webdriver browser = webdriver.Firefox() browser.get('https://accounts.google.com/ServiceLogin?')
因为elem = browser.find_element_by_name()我已经尝试过:
elem = browser.find_element_by_name()
elem=browser.find_element_by_name('input id="Email"') elem=browser.find_element_by_name('input id="Email" class="" type="email" spellcheck="false" value="" placeholder="Email" name="Email"') elem=browser.find_element_by_name('input id="Email" class=""') elem=browser.find_element_by_name('id="Email" class="" type="email" spellcheck="false" value="" placeholder="Email" name="Email"') elem=browser.find_element_by_name('id="Email" class=""')
这些都不起作用。
试试这个:
elem=browser.find_element_by_name("Email")
find_element_by_name期望nameHTML行中的的值。所以在这种情况下name="Email",你会给find_element_by_name("Email")。
find_element_by_name
name
name="Email"
find_element_by_name("Email")