2017-05-24 4 views
0

인증을위한 팝업이 필요합니다. 로그인을 위해 다른 링크로 리디렉션되고 유효한 로그인시 원래 URL로 돌아가는 Selenium으로 인트라넷 웹 사이트를 열려고합니다. 예를 들어 - webdriver를 시작하고 원래 사이트 URL https://DemoOriginalWebsite.Com로 이동하면 브라우저가 https://Validateyourselfbeforeaccessing.com:9030으로 리디렉션되고 사용자 ID와 비밀번호를 입력하는 팝업 창이 나타납니다.인증 방법 입력란에 Selenium C#

Popup window

나는 아래와 같은 자격 증명을 전달하는 시도했지만 작동하지 않았다.https://username:pswdValidateyourselfbeforeaccessing.com:9030

인증 URL 직접 액세스 할 수 없습니다 :http://username:[email protected]

2보십시오 :

1 시도해보십시오.

내 실제 코드 :

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:[email protected]"); 

어떤 제안하십시오.

답변

0

AutoIT를 사용해야합니다. AutoIT를 설치하고 AutoIT에 스크립트를 작성한 다음 .exe 파일로 내 보냅니다. 이 .exe는 셀레늄으로 전화해야합니다.

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

감사합니다. 나 해보자. –

+0

쿨 형. AutoIT는 놀라운대로합니다. 웹 드라이버를 인터넷 익스플로러로 바 꾸었습니다. 적절한 윈도우 팝업을 제공합니다. 독자들에게 참조 할 수 있도록 작업 코드를 추가 할 예정입니다. 감사. –

+1

유익한 비디오도 얻었습니다. https://youtu.be/civzNtKTCD0 –

1

여기에 나와있는 방법이 있습니다.

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(); 

자습서 나는 따랐다. Tutorial 1Tutorial 2