我试图得到文本“不正确的凭据”,这是在页面(js)当用户输入错误的用户名和密码。。。在
login_button.click()
self.driver.implicitly_wait(10) # seconds
get_conformation_message = self.driver.find_element(By.XPATH, '//*[@id="toast-container"]/div/div[1]')
noz.assert_equal(get_conformation_message.text, "Incorrect Credentials")
我设置了10秒的等待时间以确保元素在页面上,但是我的测试仍然失败。。。。在
noz.assert_equal(get_conformation_message.text, "Incorrect Credentials") nose.proxy.AssertionError: '' != 'Incorrect Credentials'
+ Incorrect Credentials
这是呈现的html。。。在
^{pr2}$我怎样才能让它在硒中发挥作用?在
我无法评论rts的问题
因为我没有足够的声望点数。答案是:
在单击“登录”按钮之前,请执行以下操作:
打开“开发工具”->;“元素”选项卡
在body标记处创建一个断点,甚至更好:您要查找的元素的父标记,选择break on subtree modifications
按F8
单击“登录”
然后逐步执行,直到看到toastr
检查toastr并检索xpath/cssSelector
这样我就可以得到足够的声誉点数,这样我就可以对事情发表评论了:D
您可以使用显式等待(在我的案例中每次都有效):
相关问题 更多 >
编程相关推荐