HTML:
<div id="NarrowResultsSection">
<div id="b_narrowClearAll"><span>Your Filter Selections</span> <a href="/search/everything?searchField=*&category=everything&searchFilter=" class="narrow-clear-all">Clear All</a></div>
<div id="b_narrowClear">Books, Movies & More<a href="/search/everything?searchField=*&category=everything&searchFilter=">Remove</a></div>
<div id="b_narrowMedium">Medium: Books <a href="https://qa.qbpl.org/search/book?searchField=*&category=book&searchFilter=%20%20sm_format:book.audiobook">Remove</a></div>
<div id="b_narrowMedium">Medium: Audiobooks <a href="https://qa.qbpl.org/search/book?searchField=*&category=book&searchFilter=%20sm_format:book%20">Remove</a></div>
</div>
错误消息:
org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element
答案 0 :(得分:0)
要单击Medium: Audiobooks
,请使用WebdriverWait
和elementToBeClickable
,然后单击元素。您可以使用以下xpath。
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@id='b_narrowMedium'][contains(.,'Medium: Audiobooks')]/a[contains(.,'Remove')]"))).click();