2015-01-09 2 views
1

나는 watir-webdriver 테스트 스크립트를 작성하여 app에 파일을 업로드하고 있습니다. 내 응용 프로그램은 검도 위젯을 사용합니다. 아래 http://demos.telerik.com/kendo-ui/upload/indexWindows 파일 업로드 상자와 watir로 상호 작용할 수 없습니다.

코드를 디버깅 할 때 대화 할 수 있지만 함께 실행하면 Windows 대화 상자 모달이 포커스를 얻지 못하는 것처럼 보입니다. 아래 코드 :

require 'win32ole' 

sleep 1 
wsh = WIN32OLE.new('Wscript.Shell') 
## open the windows dialog modal. 
@browser.div(:class => "k-button k-upload-button").click 

### Code times out after the above click, it never executes the below steps as app looses focus,  don't know how I can switch the focus to windows modal and execute below code. 

@browser.windows.last.use do 
    sleep 2 
    wsh.AppActivate("File Upload") 
    sleep 2 
    wsh.SendKeys "{TAB}" 
    sleep 1 
    wsh.SendKeys("file path") 
    sleep 1 
    wsh.SendKeys "~" 
end 

오류 :

순 :: ReadTimeout (NET : ReadTimeout)

+0

에는'<입력 유형 = "파일">'태그가 없습니다? 있다면,'# file_field'는 그 트릭을 할 것입니다. – orde

+0

예, 그곳에, 나는 멀티 스레딩으로 해결책을 찾아 낼 수있었습니다. – cookienut

답변

0
I was able to figure the solution for my problem by multi-threading . 

def threaded 
    @filepath= upload_filepath ## reading from YAML 
    t1=Thread.new { select_files } 
    t2=Thread.new { file_upload(@filepath) } 
    t1.join 
    t2.join 
    end 

def select_files_click_button 
    @browser.div(:class => "k-button k-upload-button").click 
    sleep 2 
end 

def file_upload(filepath) 
    #def file_upload 
    require 'win32ole' 
    sleep 3 
    wsh = WIN32OLE.new('Wscript.Shell') 
    sleep 2 
    wsh.AppActivate("File Upload") 
    sleep 4 
    wsh.SendKeys "{TAB}" 
    sleep 3 
    wsh.SendKeys("#{filepath}") 
    sleep 2 
    wsh.SendKeys "~" 
    sleep 2 
    @browser.windows.first.use 
    end 
관련 문제