您的位置:首页 > 其它

selenium如何解决window安全验证问题

2015-06-04 13:53 477 查看
解决办法

IE浏览器:

1.使用autoit,捕捉到控件后,编写au3脚本,生成exe,然后java调用exe

au3脚本

Dim $account = "username"
Dim $pwd = "password"
Dim $dialogTitle = "Windows 安全"
WinActivate($dialogTitle)
WinWaitActive($dialogTitle)
Sleep(1*100)
ControlSetText($dialogTitle,"","Edit1",$account)
Sleep(1*100)
ControlSetText($dialogTitle,"","Edit2",$pwd )
ControlClick($dialogTitle,"","Button2")
Sleep(1*100)


java调用代码,可以自行把绝对路径改成相对路径

Runtime rn = Runtime.getRuntime();
Process p = null;
try {
p = rn.exec("\"D:/workspace/test.exe\"");
} catch (Exception e) {
System.out.println("Error exec!");
}


2.更改注册表

保存下面内容保存为reg,双击

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE]
"iexplore.exe"=dword:00000000

火狐浏览器

在地址前面加上用户名和密码,如:http://username:password@127.0.0.1:8888/index

参考资料:http://m.blog.csdn.net/blog/lan0227/36384201
http://blog.csdn.net/max229max/article/details/34456507
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: