我've been trying to fix this issue for a while now, none of the existing questions helps. I' m使用the node implementation of selenium webdriver,版本^ 4.0.0-alpha.1并使用最新的chromedriver在chrome上测试它 .
我正在尝试清除 <input/>
的文本,其中 type="email"
. Webdriver有一个built in command,但是当我执行它时输入没有't clear (and there'没有错误):
// This populates the text field, no problem
driver.findElement(By.id("model-auth-email")).sendKeys("test@gmail.com");
// This is executed without error, but nothing happens, text field isn't cleared
driver.findElement(By.id("model-auth-email")).clear();
我不能使用CTRL'a' - > BACKSAPCE方法,因为我使用的是Mac,它将是COMMAND'a' . 根据我能找到的各种线程,Chrome驱动程序已经(仍然没有解决)支持本机osx COMMAND按钮输入6年的问题 .
我也可以做一些类似循环BACKSPACE输入的东西,直到它被清除,尽管这很糟糕 .
关于为什么 .clear()
无声无效的任何想法?
2 回答
从Webdriver文档, findElement 将返回一个promise,因此您可以尝试:
一个原因可能是你的输入有
type="email"
而不是type="text"
. 该文件明确地说:如果是这种情况,也许这可以请求Selenium,因为电子邮件也是文本 .