本文介绍了selenium clear() 命令不清除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用 Java 编写 selenium 脚本已经有一段时间了.我今天遇到了一个很奇怪的问题.问题来了:
I have been writing selenium scripts for a while in Java. I encountered a very weird issue today. Here is the issue:
我使用 webelement.clear() 方法清除了一个文本字段,稍后在执行下一个命令(单击事件)时,我之前清除的文本区域现在填充了之前填充的值.
I cleared a text field using webelement.clear() method, later while executing next command (click event), the text area I had previously cleared, is now populated with previously filled value.
这里是代码片段:
mobileNumField.get(0).clear();
Thread.sleep(4500);
emailAddress.get(0).click();
emailAddress.get(0).clear();
Thread.sleep(4500);
emailAddress.get(0).sendKeys(Keys.TAB);
推荐答案
遇到了类似的问题.输入字段已清除,但错误消息未更新.似乎某些输入字段只有在您输入和删除字符时才能正常工作:
Faced a similar problem. The input field is cleared but the error message is not updated. It seems that some input fields work correctly only if you enter and delete a character:
element.sendKeys(text);
element.sendKeys(Keys.SPACE, Keys.BACK_SPACE);
这篇关于selenium clear() 命令不清除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!