[英]raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed
I have a problem with Selenium Webdriver, trying to locate the element, the program gives an error "raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed"我有 Selenium Webdriver 的问题,试图定位元素,程序给出错误“raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Assertion failed”
My code is with a page-object model: My code: 1st part -我的代码是一个页面对象模型:我的代码:第一部分 -
def located_element(self, locator):
wait = WebDriverWait(self.driver, 30)
element = wait.until(EC.presence_of_element_located(locator))
return element
2nd part第二部分
def enter_email(self, user):
email_field = self.located_element(self.locator.Email)
email_field.click()
email_field.send_keys(Users.get_user(user)["email"])
3rd(running)第三(运行)
I have tried some recommendations from related issues but it didn't help me.我尝试了相关问题的一些建议,但没有帮助我。 At first, it couldn't find the element, that's why I added EC, but now it raises an error.
起初,它找不到元素,这就是我添加 EC 的原因,但现在它引发了错误。 Please, help me, how can I handle the Exception.
请帮助我,我该如何处理异常。 I have tried the locator both with xpath and css-selector too.
我也尝试过使用 xpath 和 css-selector 的定位器。
In the first time you open the site the email field doesn't have class input-error
.在您第一次打开网站时,电子邮件字段没有类
input-error
。 Try尝试
email_field = self.located_element((By.CSS_SELECTOR, '[data-login-source="loginPage"] [name="email"]'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.