I'm a beginner in selenium webdriver and I'm unable to click one particular dropdown so that I can select the values from the dropdown. Here is my webdriver code:
driver.findElement(
By.xpath("/html/body/div[16]/div[2]/div/div/div/div[1]/div[2]/span/span/span[1]"))
.click();
Here is my HTML code:
<span title="" class="k-widget k-dropdown k-header" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="ddlSaleItem_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" style="width: 115%;" aria-activedescendant="3597e7c2-7206-4a69-b9ca-a99cd87699aa">
<span unselectable="on" class="k-dropdown-wrap k-state-default k-state-focused">
<span unselectable="on" class="k-input"></span>
<span unselectable="on" class="k-select">
<span unselectable="on" class="k-icon k-i-arrow-s">select</span>
</span>
</span>
<div id="ddlSaleItem" data-id="" style="width: 115%; display: none;" data-role="dropdownlist">
</div>
</span>
单击下拉列表会导致WebDriverWait
() 和elementToBeClickable
() 以及以下Xpath
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='select']"))).click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.