尽管Web驱动程序能够找到元素,但无法单击它。
已应用隐式等待。另外,尝试显式等待,但是当显式等待获取错误元素未附加到页面
时WebElement sales_order_doc_type_dropdown = driver.findElement(By.xpath("//input[@id='WD67']"));
sales_order_doc_type_dropdown.click();
元素的HTML代码
<input id="WD67" ct="CB" lsdata="{1:'26.4ex',5:true,8:'WD68',9:'1'}" lsevents="{Select:[{ResponseData:'delta',ClientAction:'submit'},{}]}" type="text" autocomplete="off" tabindex="0" ti="0" class="urEdf2TxtEnbl lsEdfLeftBrdRadius lsEdf3TxtHlpBtn urBorderBox lsControl--explicitwidth" readonly="" value="" style="vertical-align:top;width:26.4ex;">
答案 0 :(得分:0)
所需元素是动态元素,因此click()
上的元素必须引起elementToBeClickable()
的 WebDriverWait ,并且您可以使用以下{{3 }}:
cssSelector
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input[id^='WD'][ct='CB'][lsevents*='ClientAction']"))).click();
xpath
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[starts-with(@id, 'WD') and @ct='CB'][contains(@lsevents, 'ClientAction')]"))).click();