Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Selenium C在chrome中填写认证要求弹出窗口#_C#_Selenium_Selenium Webdriver_Chrome Web Driver - Fatal编程技术网

C# 如何使用Selenium C在chrome中填写认证要求弹出窗口#

C# 如何使用Selenium C在chrome中填写认证要求弹出窗口#,c#,selenium,selenium-webdriver,chrome-web-driver,C#,Selenium,Selenium Webdriver,Chrome Web Driver,我正在尝试用Selenium打开一个内部网站,它会重定向到另一个链接进行登录,并在有效登录时返回到原始URL。例如,当我启动webdriver并导航到原始站点URLhttps://DemoOriginalWebsite.Com浏览器被重定向到https://Validateyourselfbeforeaccessing.com:9030并显示下面的弹出窗口以输入用户id和密码 我试图通过下面的证书,但没有成功 尝试1: 尝试2: 无法直接访问身份验证URL 我的实际代码: IWebDriver

我正在尝试用Selenium打开一个内部网站,它会重定向到另一个链接进行登录,并在有效登录时返回到原始URL。例如,当我启动webdriver并导航到原始站点URL
https://DemoOriginalWebsite.Com
浏览器被重定向到
https://Validateyourselfbeforeaccessing.com:9030
并显示下面的弹出窗口以输入用户id和密码

我试图通过下面的证书,但没有成功

尝试1:

尝试2:

无法直接访问身份验证URL

我的实际代码:

IWebDriver chromeDriver;
ChromeOptions options = new ChromeOptions();
options.AddArgument("disable-infobars");
options.AddUserProfilePreference("credentials_enable_service", false);        
options.AddUserProfilePreference("profile.password_manager_enabled", false);
chromeDriver = new ChromeDriver(options);
chromeDriver.Manage().Window.Maximize();     chromeDriver.Navigate().GoToUrl(@"http://username:pswd@DemoOriginalWebsite.Com");

请提供任何建议。

您必须使用AutoIT。安装AutoIT,在AutoIT中编写脚本并将其导出为.exe文件。这个.exe你将不得不调用你的selenium

WinWait("Untitled - Google Chrome", "" , 10)) //This will wait for 10 seconds for window with the specified title
WinActivate("Untitled - Google Chrome"); // This will send the focus of the cursor to the window with the specified title
Send("username");

//1st argument : moves the cursor's focus from Username textbox to Password text box.  
//2nd argument : false,  over here tell that it is not a text but raw key
Send("{TAB}", false); 
Send("password");
Send("{Enter}", false);// this will mimic the action of pressing enter button.

您必须使用AutoIT。安装AutoIT,在AutoIT中编写脚本并将其导出为.exe文件。这个.exe你将不得不调用你的selenium

WinWait("Untitled - Google Chrome", "" , 10)) //This will wait for 10 seconds for window with the specified title
WinActivate("Untitled - Google Chrome"); // This will send the focus of the cursor to the window with the specified title
Send("username");

//1st argument : moves the cursor's focus from Username textbox to Password text box.  
//2nd argument : false,  over here tell that it is not a text but raw key
Send("{TAB}", false); 
Send("password");
Send("{Enter}", false);// this will mimic the action of pressing enter button.

我是这样想的

1-将AutoIt NuGet包添加到项目中

2-使用如下:

IWebDriver driverIE = new InternetExplorerDriver();
driverIE.Manage().Window.Maximize();
driverIE.Navigate().GoToUrl(@"https://DemoOriginalWebsite.Com");
AutoItX.ControlFocus("Windows Security", "", "Edit1");
AutoItX.ControlSetText("Windows Security", "", "Edit1","userid");
AutoItX.ControlFocus("Windows Security", "", "Edit2");
AutoItX.ControlSetText("Windows Security", "", "Edit2", "password");
AutoItX.ControlClick("Windows Security", "", "Button2");
//Do your work.
driverIE.Dispose();
我遵循的教程。
这就是我的想法

1-将AutoIt NuGet包添加到项目中

2-使用如下:

IWebDriver driverIE = new InternetExplorerDriver();
driverIE.Manage().Window.Maximize();
driverIE.Navigate().GoToUrl(@"https://DemoOriginalWebsite.Com");
AutoItX.ControlFocus("Windows Security", "", "Edit1");
AutoItX.ControlSetText("Windows Security", "", "Edit1","userid");
AutoItX.ControlFocus("Windows Security", "", "Edit2");
AutoItX.ControlSetText("Windows Security", "", "Edit2", "password");
AutoItX.ControlClick("Windows Security", "", "Button2");
//Do your work.
driverIE.Dispose();
我遵循的教程。
谢谢。让我试试,酷兄弟。你真是太棒了。我已将web驱动程序更改为Internet Explorer,因为它为我提供了正确的windows弹出窗口。将添加我的工作代码以供读者参考。谢谢。很高兴我能帮上忙。谢谢,谢谢。让我试试,酷兄弟。你真是太棒了。我已将web驱动程序更改为Internet Explorer,因为它为我提供了正确的windows弹出窗口。将添加我的工作代码以供读者参考。谢谢。很高兴我能帮上忙。谢谢