【发布时间】:2020-12-02 04:38:48
【问题描述】:
我已经尝试解决这个问题一段时间了,现有的问题都没有帮助。我正在使用 the node implementation of Selenium WebDriver,版本 ^4.0.0-alpha.1 并使用最新的 ChromeDriver 在 Chrome 上对其进行测试。
我正在尝试清除 <input/> 的文本,其 type="email"。 WebDriver 为此有一个built in command,但是当我执行它时,输入不清除(并且没有错误):
// 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 & BACKSPACE 方法,因为我使用的是 Mac,它会是 CMD+a。根据我能找到的各种线程,ChromeDriver 支持本机 OSX CMD 按钮输入的问题(仍未解决)已有 6 年之久。
我还可以执行诸如循环 BACKSPACE 输入之类的操作,直到它被清除为止,尽管这很 hacky。
关于为什么 .clear() 无法正常工作的任何想法?
【问题讨论】:
-
你确定你发布了正确的 github 链接吗?
-
@shkaper 是的,这是正确的
标签: javascript node.js selenium-webdriver selenium-chromedriver