所以我完全是初学者,我遇到了一个问题。所以这是我计划的一部分:
browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/signin'
'/v2/sl/pwd?service=mail&passive=tru'
'e&rm=false&continue=https%3A%2F%2Fmai'
'l.google.com%2Fmail%2F&ss=1&scc=1<mp'
'l=default<mplcache=2&emr=1&osid=1&f'
'lowName=GlifWebSignIn&flowEntry=AddSe'
'ssion&cid=0&navigationDirection=forward'))
username = browser.find_element_by_id('identifierId')
username.send_keys(usernameStr)
nextButton = browser.find_element_by_id('identifierNext')
nextButton.click()
password = WebDriverWait(browser, 10).until(
EC.presence_of_element_located(By.CLASS_NAME('whsOnd zHQkBf')))
password.send_keys(passwordStr)
第一部分,它把我的用户名工作得很好,也在那一部分,它点击下一步按钮的工作。你知道吗
但我不能用密码。在username中有ID标记,可以很容易地按ID找到元素,但password没有这个。这是密码HTML:
<input type="password" class="whsOnd zHQkBf" jsname="YPqjbf" autocomplete="current-password" spellcheck="false" tabindex="0" aria-label="Vnesite geslo" name="password" autocapitalize="off" autocorrect="off" dir="ltr" data-initial-dir="ltr" data-initial-value="">
我试着把它称为类名或链接文本,但它就是不起作用。 谢谢你的回答
下面的链接是针对selenium的,但在Chrome上应该是一样的:按标签名称(“input”)查找元素或按名称(“password”)查找元素都应该工作
https://selenium-python.readthedocs.io/locating-elements.html
谢谢你的帮助B。走吧,但你贴的东西对我没什么帮助。你知道吗
我决定重写代码,用和第一部分相同的逻辑
它现在神奇地工作了。谢谢你的帮助
我也有同样的问题,这是我找到的解决办法。你必须让程序登录到你的电子邮件,所以你必须禁用安全设置。 这是一种更直接的使用SMTP库的方法。你知道吗
制造商
相关问题 更多 >
编程相关推荐