2013-02-21 4 views

답변

1

사용

Then I enter "abd" into the "username" input field 
1

먼저 당신이 "_steps.rb"파일이 사용자 정의 기능을 추가 할 필요가 그런

Then /^I enter constant text "([^\"]*)" to text field number (\d+)$/ do |texts,index| 

    index = index.to_i 
    screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0) 
    clearTextfield(index-1) 
    enterDataToTextfieldNum(texts, index-1) 
    sleep(STEP_PAUSE) 
end 

def enterDataToTextfieldNum(text, index) 
    index = index.to_i 
    text = text.to_s 
    if index>=0 
     sleep(0.2) 
     touch("textField index:#{index}") 
     sleep(0.4) 
     await_keyboard 
     sleep(0.2) 
     keyboard_enter_text("#{text}") 
     sleep(0.2) 
     done 
     sleep(0.3) 
    end 
end 

def clearTextfield(index) 
    index = index.to_i 

    if query("textField index:#{index}",:text).first 
     length=query("textField index:#{index}",:text).first.length 
    else 
     length=0 
    end 
    if (index>=0)&&(length>0) 
     touch("textField index:#{index}") 
     await_keyboard 
     for i in 0..length-1 
     keyboard_enter_char("Delete",false) 
     end 
    end 
end 

당신은 호리병박 기능 파일을 호출 할 수 있습니다

Then I enter constant text "Old road" to text field number 3 

여기 textfileld 번호를 사용했으나 원하는 경우 텍스트 필드 이름을 사용하여 편집 할 수 있습니다. 도움이 필요하시면 알려주세요. 감사합니다. .

+1

이걸 실행할 때 텍스트 필드를 건 드리면 키보드가 나타나고 다음과 같은 오류가 발생합니다. 명령 uia.typeString ('Old road')에 대해 UIAutomation 실행 루프를 기다리는 중 시간이 초과되었습니다. 색인 대기 중 : 2 (RunLoop :: TimeoutError) ./features/step_definitions/my_first_steps.rb:24:in'enterDataToTextfieldNum ' ./features/step_definitions/my_first_steps.rb:11:in'/^상수 텍스트 입력 ' (\ d +) $/' features/my_first.feature : 8 : in'그런 다음 텍스트 필드 번호 1에 "오래된 도로"를 입력하십시오. – iCoder

+0

Yaseen, 수 있습니까? 단계 정의와 단계를 완전히 언급하십시오. 여기에서 검토 할 수 있습니다. –

관련 문제