gpt4 book ai didi

java - 无法在 Safari 13.0.4 中使用 Selenium 单击元素

转载 作者:行者123 更新时间:2023-12-01 19:12:10 34 4
gpt4 key购买 nike

org.openqa.selenium.WebElement.click()org.openqa.selenium.interactions.Actions.click() 等方法不会触发任何运行时出错,而且单击操作也不会发生。尝试使用 Javascript,但我尝试单击的元素似乎无法单击(在 Chrome 的开发人员工具中返回未定义)

这是该元素的 html

<div class="flatpickr-calendar animate showTimeInput arrowTop open" tabindex="-1" style="width: 245px; top: 719px; left: 1603.17px; right: auto;">
<div class="flatpickr-months">...</div>
<div class="flatpickr-innerContainer">
<div class="flatpickr-rContainer">
<div class="flatpickr-weekdays">...</div>
<div class="flatpickr-days" tabindex="-1" style="width: 245px;">
<div class="dayContainer">
<span class="flatpickr-day " aria-label="December 29, 2019" tabindex="-1">29</span>
</div>
</div>
</div>
</div>
</div>

最佳答案

要单击该元素,您必须为 elementToBeClickable() 引发 WebDriverWait,并且您可以使用以下任一 Locator Strategies :

  • css选择器:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.dayContainer>span.flatpickr-day[aria-label='December 29, 2019']"))).click();
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='dayContainer']/span[@class='flatpickr-day ' and text()='29']"))).click();

关于java - 无法在 Safari 13.0.4 中使用 Selenium 单击元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59468360/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com