我有一个网站与以下HTML。首先,要素是:
<div class="hidden sc-cHGsZl ghXVcK" role="alert" id="login-error"></div>
然后,在您登录失败后,它将更改为:
<div class="sc-cHGsZl ghXVcK" role="alert" id="login-error">
<span>Incorrect email address and / or password.<br>
Do you need help <a href="/login/resetpassword?email=xxxxx">logging in</a>?
</span>
</div>
我目前的工作:
errors = driver.find_element_by_xpath(
"//div[@id='login-error']//span[contains(., 'Incorrect email address and / or password.')]")
我有以下几个问题:
errors
的内容;我该怎么做?
谢谢你们!祝你今天愉快李>
问题1。我应该如何检查未成功登录
基本上,您可以将登录代码封装在一个文件中,尝试除外:
代码:
对于第二个问题,你可以用这句话
在该行之后的if块中
print("if code has reached here that means login was not successful")
相关问题 更多 >
编程相关推荐