Ruby 如何使用selenium webdriver单击确认窗口上的“确定”按钮?
我正在使用网页中的Ruby 如何使用selenium webdriver单击确认窗口上的“确定”按钮?,ruby,selenium-webdriver,Ruby,Selenium Webdriver,我正在使用网页中的selenium webdriver编写文件删除脚本。现在,当我点击下图中的红色交叉按钮时,页面上出现了另一个确认窗口 知道如何点击OK按钮吗 您是否尝试过以下逻辑 Alert alert = driver.switch_to.alert alert.accept 下面的代码最终用于处理所提到的图片modal窗口: driver.switch_to.alert.accept 从图片上看,它不像一个真正的弹出窗口(即可能只是一个带有按钮元素的div标签)。查看弹出窗口的htm
selenium webdriver
编写文件删除脚本。现在,当我点击下图中的红色交叉按钮时,页面上出现了另一个确认窗口
知道如何点击OK
按钮吗
您是否尝试过以下逻辑
Alert alert = driver.switch_to.alert
alert.accept
下面的代码最终用于处理所提到的图片modal
窗口:
driver.switch_to.alert.accept
从图片上看,它不像一个真正的弹出窗口(即可能只是一个带有按钮元素的div标签)。查看弹出窗口的html会很有用。@JustinKo当我点击那边的红十字会时,在删除该文件之前,该窗口会弹出确认窗口。现在我的问题是如何点击OK
按钮。获取错误为D:\Rubyscript\my ruby learning days\Scripts>W9_File\u delete.rbd:/Rubyscript/my ruby learning days/Scripts/W9_File\u delete.rb:117:in
':u defined methodAlert',main:Object(nomethodorr)
我认为您需要导入org.openqa.selenium.Alert类。