2016-06-03 1 views
1

나는 팝업 창에 로그인해야하고 사람들이 제안한 모든 방법을 테스트했으며 그 중 아무 것도 작동하지 않았습니다! 그래서 내가하려는 것은 URL로 가서 바로 username\tpassword을 입력하고 Enter을 누르는 것입니다. 일반적으로이 경우 input 요소를 선택하여 수행 할 수 있지만이 경우에는 수행 할 수 없습니다. 요소를 선택하지 않고 어떻게 입력 할 수 있습니까? 포커스 가정요소를 선택하지 않고 Selenium의 기본 Autothentication

enter image description here

+0

팝업으로 생성 된 새 프레임에 초점을 맞추어 보았습니까? –

+0

@JonathanKempf'IAlert alert = driver.SwitchTo(). Alert();'? 새 프레임으로 전환하더라도 엘리먼트를 선택해야합니까? – Yar

+0

내가 잘못 본 것이 아니라면로드 된 HTML에 삽입되거나 참조 된 JavaScript의 경고가 아닙니다. 이것이 BASIC AUTH 대화 상자입니다. 셀레늄에서 BASIC AUTH를 수행하는 것은 [해결 된 문제] (https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/34)이지만 [해결 방법] (https :// /github.com/seleniumhq/selenium-google-code-issue-archive/issues/34#issuecomment-191403370). –

답변

3

이가 대체로 사용할 수있는 것은 내가 시도하고 근무 무슨이다 나도 과거에.

System.Windows.Forms.SendKeys.SendWait("UserNoome"); 
System.Windows.Forms.SendKeys.SendWait({TAB}); 
System.Windows.Forms.SendKeys.SendWait("Passwoord"); 
+0

매력처럼 작동합니다. 감사합니다 캄. – Yar

+0

'로그인'버튼을 누르기 만하면 비밀번호를 입력 한 후 다시 Tab을 눌러야합니다. 마지막 단계는'System.Windows.Forms.SendKeys.SendWait ("\ t \ n");' – Yar

+0

@HoomanYar와 같아야합니다. 마지막 단계는'System.Windows.Forms.SendKeys.SendWait ({ENTER});' –

0

는 프레임이다.

Actions action = new Actions(webdriver); //replace with your driver 
action.sendKeys("username").perform(); 
action.sendKeys("\t").perform(); //possibly Keys.TAB 
action.sendKeys("password").perform(); 
action.sendKeys("\n").perform(); //possibly Keys.ENTER 

편집 : 다음 필요한 [자바 코드]에 대한 Actions를 사용해보십시오 또한 keyDown(Keys.TAB)sendKeys("\t")

+0

이 작동하지 않습니다. 첫 번째'sendKeys'에서'OpenQA.Selenium.UnhandledAlertException'을줍니다. – Yar

관련 문제