javascript - Dropdown cannot be selected in Selenium - Element not visible -
i'm attempting select dropdown box via selenium , being told following
element not visible , may not interacted with
after searching around bit i've tried following still being given same error:
webelement inputelement = driver.findelement(by .id("diningavailabilityform-searchtime")); ((javascriptexecutor) driver).executescript( "arguments[0].checked = true;", inputelement); ((javascriptexecutor) driver).executescript( "arguments[0].checked = true;", inputelement); ((javascriptexecutor) driver) .executescript("$(\"#diningavailabilityform-searchtime\").show()"); ((javascriptexecutor) driver).executescript( "arguments[0].checked = true;", inputelement); driver.switchto().activeelement(); new select(inputelement).selectbyvisibletext("dinner"); however,this results in same error. when open page in browser can see dropdown, can click on dropdown. however, said - using bit of code doesn't achieve need.
the input element returns value correct. made sure check correct throwing in errors , failed expected.
edit 2:
here's html
<span class="selectbox medium standardformelement status-closed" id="searchtime-wrapper" data-plugins="[["pepselectbox",{"maxselectionslength":"20","maxdisplayoptions":"8","displayscrollbar":"1","displayspecialdropdown":"1","displayspecialdropdownheight":"21","checkiconactive":"1","highlightselected":"1"}]]" data-prependliststyleenhancements="[]" data-appendliststyleenhancements="[]" data-richoptioncontents="[]" data-extraoptionclass="[]" data-richoptgroup="[]" data-a11ytext=" - opens menu"> <span class="selectbox-nojs" style="display: none;"> <select name="searchtime" id="diningavailabilityform-searchtime" class="searchtime inputelement" min="06:30:00" max="22:30:00" allday="00:00:00 23:30:00" data-plugins="[["pepmealtimeoptionmodifier"]]"> <option value="80000712" label="breakfast" selected="selected">breakfast</option> <option value="80000717" label="lunch">lunch</option> <option value="80000714" label="dinner">dinner</option> </select> </span> <span class="richselectarrowicon uiglobalsprite"></span> <div class="select-toggle hoverable" aria-haspopup="true" aria-owns="diningavailabilityform-searchtime-dropdown-list" aria-describedby="diningavailabilityform-searchtime-label" aria-labelledby="diningavailabilityform-searchtime-label" role="button" tabindex="0"><span class="select-value" data-activeoptionclass=""><span class="rawoption"><span class="accessibletext hidden">time required - opens menu - </span>dinner</span> </span> </div> <div class="listwrapper"> <span class="scrollbartrack"></span> <div class="innerlistwrapper"> <ol class="dropdown-list" id="diningavailabilityform-searchtime-dropdown-list" aria-hidden="true" role="listbox" aria-label="time&nbsp;required - opens menu"> <li role="option" data-value="80000712" data-display="breakfast" data-extraoptionclass="" class="selectoption" id="diningavailabilityform-searchtime-0" aria-setsize="36" aria-posinset="1"><span class="rawoption"><span class="accessibletext hidden">time required - opens menu - </span>breakfast</span> </li> <li role="option" data-value="80000717" data-display="lunch" data-extraoptionclass="" class="selectoption" id="diningavailabilityform-searchtime-1" aria-setsize="36" aria-posinset="2"><span class="rawoption"><span class="accessibletext hidden">time required - opens menu - </span>lunch</span> </li> <li role="option" data-value="80000714" data-display="dinner" data-extraoptionclass="" class="selectoption" id="diningavailabilityform-searchtime-2" aria-setsize="36" aria-posinset="3"> </ol> </div> </div> <span class="shadow-mask"></span> </span>
you probarly trying use element before visible.
webdriverwait wait = new webdriverwait(driver, 30); wait.until(expectedconditions.refreshed(expectedconditions.visibilityofelementlocated(by))); wait.until(expectedconditions.refreshed(expectedconditions.elementtobeclickable(by))); effective wait methods situation
if didnt work, try
waituntil(waits.elementdisplayed(webelement));
Comments
Post a Comment