【问题标题】:Unable to click on 'OK' button in the web alert无法单击网络警报中的“确定”按钮
【发布时间】:2021-10-11 08:12:59
【问题描述】:

我正在尝试使用 selenium webdriver 警报界面在附加的弹出窗口中单击“确定”按钮。

当我使用辅助功能检查器检查“确定”按钮时,它显示了以下属性。

target.processes()["Google Chrome"].frontWindow().images()["Chrome critical alert"].click()
target.processes()["Google Chrome"].frontWindow().buttons()["OK"].click()

所以,我尝试使用 webdriver alert 来点击“确定”,但没有成功。

Alert alert = driver.switchTo().alert();

alert.accept();

在这方面花费了足够的时间,但找不到解决方案。在这里感谢任何帮助!

【问题讨论】:

    标签: java macos selenium-webdriver selenium-chromedriver icloud-drive


    【解决方案1】:

    在我看来,这不像是浏览器“警报”框,所以 Alert 方法找不到它。它也不像通常意义上的“弹出窗口”(一个单独的桌面窗口)。我从您的描述中猜测它是页面上的常规 HTML 元素。因此,您需要通过通常的 Selenium 元素查找技术找到 OK 按钮,然后在该元素上单击()。

    【讨论】:

      猜你喜欢
      • 2010-11-23
      • 2013-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 2018-05-01
      • 2023-02-26
      相关资源
      最近更新 更多