如何使用Watin IE处理Windows安全警报对话框 [英] How to handle Windows Security alert dialog box using Watin IE
问题描述
由于网站禁止ip几个请求后。我设置一个bool ipbanned = true当ip被禁止。在这种情况下,我希望改变IP。 SetProxy方法使用端口成功地更改了ip地址。
但是下一个请求我得到这个屏幕: -
注意: - 第一个红色条显示IP地址,第二个显示服务器名称
我应该如何设置该对话框中的用户名和密码来自程序,以便用户不要看到这个框,它正确设置
以下是我的代码片段使用: -
private void Start_Thread()
{
Thread pop = new Thread(populate);
pop.SetApartmentState(ApartmentState.STA);
pop.Start();
}
bool ipbanned = false;
private void populate()
{
if(ipbanned)
SetProxy(代理[0]);
///我希望在这里处理对话框。
WatiN.Core.Settings.MakeNewIeInstanceVisible = false;
WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false;
使用(IE浏览器=新的IE(URLs.mainurl))
{
///代码
}
}
private void SetProxy(string proxy )
{
//成功更改ip地址的代码。
}
任何帮助将深深感激。
谢谢:)
您必须使用 AddDialogHandler 来处理对话框
您可以参考SO问题 watin-logondialoghandlers-not-working-correct-in-windows-7 代码示例
I am trying to automate a website using WatIN IE. As the website bans the ip after few request .So I am setting a bool ipbanned =true when ip gets bannned. In that case and i wish to change the IP. The SetProxy method successfully changes the ip adress with port. but on next request I am getting this screen :-
Note: - the first red strip shows the ip address and the second one shows the server name
How should I set the username and password in this dialog box from within the program, so that user do not get to see this box and it is set correctly
Below is the code snippet I am using:-
private void Start_Thread()
{
Thread pop = new Thread(populate);
pop.SetApartmentState(ApartmentState.STA);
pop.Start();
}
bool ipbanned=false;
private void populate()
{
if(ipbanned)
SetProxy(proxies[0]);
///I wish to handle the dialog box here.
WatiN.Core.Settings.MakeNewIeInstanceVisible = false;
WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false;
using (IE browser = new IE(URLs.mainurl))
{
///code
}
}
private void SetProxy(string proxy)
{
//code which successfully changes the ip address.
}
Any help will be deeply appreciated. Thank You :)
You have to use AddDialogHandler to handle the dialog boxes.
You can refer the SO question watin-logondialoghandlers-not-working-correctly-in-windows-7 for code samples
这篇关于如何使用Watin IE处理Windows安全警报对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!