Need to pass data to hidden text field in Selenium -
i got below solution here,
jse.executescript("document.getelementsbyname('body')[0].setattribute('type', 'text');");
and passing data using sendkeys
.
but creating duplicate text field text attribute , hidden text field still exist..
you have 2 input tags. assuming want execute script against second 1 not first. also, using queryselector
, allows pass cssselector
identify element want.
note: make sure format of datetopass
correct
string datetopass = "01/01/2015"; string scripttext = "document.queryselector('.propertyyear.require').setattribute('value','" + datetopass + "')"; ((javascriptexecutor)driver).executescript(scripttext);
Comments
Post a Comment