javascript - How to interact with an element that is hidden using Selenium Webdriver? -
element properties:-
<textarea id="txtsuffixtitle" class="form-control" tabindex="3" rows="2" placeholder="suffix title" name="txtsuffixtitle" maxlength="50" cols="20" style="display: none; visibility: hidden;">suffix title </textarea>
selenium code:-
driver.findelement(by.id("txtsuffixtitle")).clear(); driver.findelement(by.id("txtsuffixtitle")).sendkeys("mr.");
error:-
element must not hidden, disabled or read-only
i found below solution in 1 of post. able interact element breaking ui.
webelement elem = driver.findelement(by.id("txtsuffixtitle")); string js = "arguments[0].style.display='inline'; arguments[0].style.visibility='visible';"; ((javascriptexecutor) driver).executescript(js, elem);
could please suggest ? can type manually due style property i.e. style="display: none; visibility: hidden; automation unable interact.
if element hidden, can't interact through selenium. javascript executor, should able like:
((javascriptexecutor)driver).executescript("document.getelementbyid('txtsuffixtitle').innertext = 'mr.'");
hope helps.
Comments
Post a Comment