如何使用java获取selenium webdriver中的警报标题?

时间:2016-10-06 07:27:22

标签: java selenium-webdriver

我可以获取提醒的内容,但需要获取警报标题。

1 个答案:

答案 0 :(得分:0)

如果警报是Windows,那么我们可以使用自动工具获取该警报的标题。要执行此操作,请下载autoit,创建以下脚本并对其进行编译以获取脚本的.exe

WinWaitActive('Name of your alert')
$heading= WinGetHandle('Name of your alert')
MsgBox(0,"Hello",$heading,0,0)

在您的java代码中添加以下行

Runtime.getRuntime().exec("C:\\Users\\user.abu\\Desktop\\fileUpload1.exe");

其中fileUpload.exe脚本的名称