从下拉菜单中,我无法从下拉菜单中选择该值。在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