草庐IT

java - Selenium WebDriver : I want to overwrite value in field instead of appending to it with sendKeys using Java

coder 2023-05-12 原文

在 WebDriver 中,如果我使用 sendKeys,它会将我的字符串附加到字段中已经存在的值。我无法使用 clear() 方法清除它,因为第二次这样做,网页会抛出一个错误,说它必须在 10 到 100 之间。所以我无法清除它,否则之前会抛出错误我可以使用 sendKeys 输入新值,如果我 sendKeys 它只是将它附加到已经存在的值。

WebDriver 中是否有任何内容可以让您覆盖字段中的值?

最佳答案

您也可以在发送 key 之前清除该字段。

element.clear()
element.sendKeys("Some text here")

关于java - Selenium WebDriver : I want to overwrite value in field instead of appending to it with sendKeys using Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3249583/

有关java - Selenium WebDriver : I want to overwrite value in field instead of appending to it with sendKeys using Java的更多相关文章

随机推荐