1

I got the below solution here,

jse.executeScript("document.getElementsByName('body')[0].setAttribute('type', 'text');");

and then passing data using SendKeys.

But it is creating duplicate text field with text attribute and hidden text field still exist..

4

1 回答 1

0

您有两个输入标签。我假设您要针对第二个而不是第一个执行脚本。另外,我正在使用querySelector它,它允许您通过cssSelector来识别您想要的元素。

注意:确保格式dateToPass正确

String dateToPass = "01/01/2015";
String scriptText = "document.querySelector('.propertyYear.require').setAttribute('value','" + dateToPass + "')";
((JavascriptExecutor)driver).executeScript(scriptText);
于 2015-03-17T05:07:20.210 回答