2014-04-09 4 views
0

팝업 창에서 요소를 찾을 수 없습니다. 그러나 팝업을 클릭 할 수 있습니다. 줄에이 오류를 얻는 것은 9-'Unable to locate element: {"method":"id","selector":"user.userName"}'Ruby Selenium WebDriver : 팝업 창에서 요소를 찾을 수 없습니다.

시나리오 :

1) 목록 열기 http://www.harley-davidson.com/store/

2) 링크

3) 사용자 이름과 암호를 입력합니다 '로그인'을 클릭은 로그인

이 오류를 해결하는 데 협조 해주십시오.

내 코드 : @orde가 언급 한 바와 같이 프레임이 자신의 DOM과 전체를 별도의 문서로 취급되기 때문에

require 'selenium-webdriver' 

browser = Selenium::WebDriver.for :firefox 
browser.manage.window.maximize 
wait = Selenium::WebDriver::Wait.new(:timeout => 15) 
browser.get "http://www.harley-davidson.com/store/"  
browser.find_element(id: "logonLinkDiv").click #to click on the sign-in link 
wait 
browser.find_element(id: "hdwcOverlay_h").click #to click on the sign-in pop-up window 

#I am unable to identify the elements 'User Name' and 'Password' in the pop-up window** 

browser.find_element(id: "user.userName").send_keys("[email protected]") 
browser.find_element(id: "user.password").send_keys("test123") 
browser.quit 
+0

게시물 수정 ... 코드 만 입력하십시오. 줄 번호를 제거하십시오. 우리는 필요 없습니다. –

+0

프레임에 팝업/오버레이가 있습니까? 그렇다면 [documentation] (https://code.google.com/p/selenium/wiki/RubyBindings)을 확인하십시오. 예 :'driver.switch_to.frame "일부 프레임"'_ _ 아래 # 프레임으로 전환 _. – orde

+0

미안 해요 ... 나는이 포럼을 처음 접했고 루비 초보자입니다. 나는 나의 미래 지위에서 이것을 반복하지 않을 것이다. – ChnMys

답변

0

, 당신은 올바른 프레임으로 전환 할 필요가있다. 연결된 페이지를 보면 다음과 같이 작동합니다.

driver.switch_to.frame "hdwcOverlayIframe" # do this first 
# now these should work 
browser.find_element(id: "user.userName").send_keys("[email protected]") 
browser.find_element(id: "user.password").send_keys("test123") 
관련 문제