從下拉菜單中,我無法從下拉菜單中選擇該值。在selenium webdriver中選擇下拉值時出現錯誤
HTML代碼:
<select id="ctl00_ContentPlaceHolder1_drp85" class="form-control select2-hidden-accessible" data-varindex="9" onchange="SetVariableValue('9', this, 'DESCENDANT - DROPDOWN')" name="ctl00$ContentPlaceHolder1$drp85" tabindex="-1" aria-hidden="true">
<option value="-1">--Select--</option>
<option value="Please don't hesitate">Please don't hesitate </option>
<option value="Please reach out to us">Please reach out to us</option>
<option value="Remember we are here for you">Remember we are here for you</option>
<option value="If you need help">If you need help</option>
<option value="If you ever need additional help">If you ever need additional help</option>
</select>
硒的webdriver代碼:
WebElement dropdown = driver.findElement(By.id("ctl00_ContentPlaceHolder1_drp85"));
selectbyindex=new Select(dropdown);
selectbyindex.selectByIndex(1);
獲取例外,因爲:
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible: Element is not currently visible and may not be manipulated".
在哪裏可以我會犯錯任何人的幫助?
的'期權value'可能不可見。在使用selectByIndex()之前,嘗試使用'click()'方法。如果這不起作用,那麼在嘗試選擇選項之前,嘗試添加'wait'直到下拉列表實際可見。 – Chaitali