【发布时间】:2020-03-20 22:33:57
【问题描述】:
我尝试了 WebDriverWait、.click()、.sendKeys(Keys.RETURN)、implicitWait、explicitWait 和许多其他方法,但我无法单击此 Web 元素。
<div class="actions style-scope tv-overlay-record-on-the-go">
<tv-button pill-action="" class="style-scope tv-overlay-record-on-the-go x-scope tv-button-2 left"><button class="style-scope tv-button"><div class="wrapper style-scope tv-button"><iron-icon id="icon" class="style-scope tv-button x-scope iron-icon-0"></iron-icon><div id="content" role="presentation" class="style-scope tv-button">Got it</div></div></button>
<div
class="hover-hint style-scope tv-button"> </div>
</tv-button>
</div>
基于上面的 HTML 代码,我创建了以下 xpath:
WebElement gotIt = driver.findElement(By.xpath("//div[@class='actions style-scope tv-overlay-account-active']//div[@id='content']"));
gotIt.click();
我相信代码运行并确认按钮在那里,因此 Web 元素已成功创建。但是,当我尝试使用多种交互方法与之交互时,什么也没有发生。
我得到的异常:org.openqa.selenium.ElementNotInteractableException: element not interactable
【问题讨论】:
-
您遇到了什么异常,请添加有问题的。另外检查是否在 iframe 内
-
检查 iframe 上是否存在“得到它”按钮。如果是这样,那么您必须在按下任何按钮之前切换到它。
标签: java html selenium automation selenium-chromedriver