HTML that I want to manipulate using JavascriptExecutor
doesn't have id
. It only contains name
, class
and tag
. Out of these only name
is unique and rest two are common for many other WebElements present in DOM.
I tried:
String javaScriptCode = "document.getElementsByName('ac118672').setAttribute('value','00031454476543');";
jse().executeScript(javaScriptCode);
this gave me error
document.getElementsByName(...).setAttribute is not a function
which is obvious because document.getElementsByName
give collection of all elements as described here https://www.w3schools.com/jsref/met_doc_getelementsbyname.asp.
So is there any other way I can change value of value
attribute using JavascriptExecutor?
References I took:
How to edit HTML (remove readonly) and type in input box using JS Executor?