[英]Trouble clearing text field with .clear() *JAVA* *ANDROID*
Hey im trying to clear a text field that my program previously sent text to by using these two lines here: 嘿,我试图通过在此处使用以下两行来清除程序以前向其发送文本的文本字段:
driver.findElement(By.xpath("//android.widget.EditText[@index='3']")).click();
driver.findElement(By.xpath("//android.widget.EditText[@index='3']")).clear();
But it only clears 2 out of 5 letters that need to cleared. 但是它只清除需要清除的5个字母中的2个。 How do i make it so it can clear all of the text at once?
我该如何做才能一次清除所有文本?
You can use javascript
executor to clear the field if clear()
is not working. 如果
clear()
不起作用,则可以使用javascript
执行程序清除该字段。
WebElement elementField = driver.findElement(By.xpath("//android.widget.EditText[@index='3']"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].value = '';", elementField);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.