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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -