使用JS输入文字,但是如果我在一个文本框中输入文字,已经输入的值被删除
我连续有3个文本框,我正在使用JS在文本框中输入文本.但问题是当我在一个字段中输入文本并转到第二个框输入文本时,第一个文本框中的值被删除.我们正在使用下面的代码来输入文本
((JavascriptExecutor) webDriver).executeScript("arguments[0].setAttribute('value','"+inputText+"')",元素);
解决方案 试试下面的:
String js = "arguments[0].setAttribute('value','"+inputText+"')"((JavascriptExecutor) webDriver).executeScript(js, element);
<块引用>
确保在第二个和第三个text
被推送之前,document.readyState == "complete"
已经实现.
I have 3 text box in a row, and I am using JS to input the texts in the text boxes. But the problem is when I enter the text in one field, and go to second box to enter the text, the value from first text box is removed. we are using the below code to input text
((JavascriptExecutor) webDriver).executeScript(
"arguments[0].setAttribute('value','"+inputText+"')",
element);
解决方案
Try the following :
String js = "arguments[0].setAttribute('value','"+inputText+"')"
((JavascriptExecutor) webDriver).executeScript(js, element);
Ensure that the before the second and third
text
is being pushed thedocument.readyState == "complete"
is achieved.
相关文章