This is the piece of HTML code on the particular page:
<input size="24" autocomplete="off" id="sch-555-et"
name="./schimage" class="x-form-text x-form-field
x-trigger-noedit" readonly="" style="width: 263px;" type="text">
It allows to browse image and refrains user to type in. I am told to skip the browsing part as it is error-prone also it isn't part of manual or automation tests.
I know how to type using JS Executor (https://www.softwaretestingmaterial.com/javascriptexecutor-selenium-webdriver/) but don't know how to edit HTML and then type.
Edit:
I don't know how my question is duplicate of Disable readonly to text box onclicking the button
Anyways I tried:
public JavascriptExecutor executeJS() {
JavascriptExecutor jsexec = (JavascriptExecutor).driver;
return jsexec;
}
executeJS().executeScript("document.getElementById('sch-555-et').removeAttribute('readonly')");
but it didn't remove "readonly" and element remain un-editable.
I tried to automate this page http://jsfiddle.net/343Rb/ also, and here it is giving error
Cannot set property 'readOnly' of null
when trying to set value of readonly as null.
Cannot read property 'removeAttribute' of null
when trying to remove readonly.
I am using Windows, Java, Selenium, Maven and TestNg
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…