本文介紹了使用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.
這篇關于使用JS輸入文字,但是如果我在一個文本框中輸入文字,已經輸入的值被刪除的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!