我正在尝试自动完成登录后出现的网站安全问题。我已经回答了6个问题,随机地提出了两个问题。
每个Xpath选项我都试图确定在'aria-label'元素中发现的特定安全问题会返回NoSuchElementException
。
我已经尝试了很多方法来解决Google Rabbit漏洞,包括:
#First Attempt
question_1=browser.find_element_by_xpath('//div[@label="name of first employer?"]')
#Second Attempt
question_1=browser.find_element_by_xpath('//form[@label="name of first employer?"]/label[text()="name of first employer?"]')
我为以下两个安全性问题添加了被检查元素的html:
<input type="password" name="first_security_question" aria-label="Unique pin #4" value="">
<input type="password" name="second_security_question" aria-label="Model of first car?" value="">
我希望在aria标签中标识特定问题,以便我可以发送适当的键来填写表单问题,但我得到的只是NoSuchElementException
。
答案 0 :(得分:1)
如果您想提出问题,请执行以下操作。
# get the question 1 element
questionEle=browser.find_element_by_xpath("//input[@name='first_security_question']")
# get the question
question_1 = questionEle.get_attribute("aria-label")
然后获取问题的答案,并将输入内容发送给问题。