0

테스트 자동화를 배우고 있습니다. Ruby 언어로 'cucumber', 'rspec', 'selenium-web driver'프레임 워크를 사용하고 있습니다. 테스트에서 거의 모든 단계를 수행 할 수있었습니다. 버튼 클릭을 자동화 할 때 오류가 발생했습니다.정의되지 않은 메서드 'click'- Webdriver

Step definitions: 
    Quando(/^clicar o botão "([^"]*)"$/) do |botaoSave| 
# @navegador.find_elements(:xpath, "//*[@id='SAVE']").trigger("click") 
    @navegador.find_elements(:xpath, "//*[@id='SAVE']").click 
end 

오류 메시지가 표시됩니다 :

E clicar o botão "SAVE"         # features/step_definitions/criarConta.rb:92 
     undefined method `click' for #<Array:0x00000002847680> (NoMethodError) 
     ./features/step_definitions/criarConta.rb:94:in `/^clicar o botão "([^"]*)"$/' 
     features/criarConta.feature:30:in `E clicar o botão "SAVE"' 
    Então a conta será cadastrada corretamente    # features/criarConta.feature:31 

Failing Scenarios: 
cucumber features/criarConta.feature:7 # Cenário: Cadastrando uma conta 

1 scenario (1 failed) 
23 steps (1 failed, 1 undefined, 21 passed) 

답변

1

find_elements는 배열을 반환합니다. //*[@id='SAVE']").click ", XPath는 알 수없는 오류 : navegador.find_element @ (: 당신은 내가 변경하는 경우 하나 개의 요소

@navegador.find_element(:xpath, "//*[@id='SAVE']").click 
+0

를 반환 find_element를 사용할 필요 요소 ('EditView'); _form.action.value = '저장'; if (check_form ('EditView')) '입력 된 제목 = "저장"accesskey = ""class = "기본 버튼"onclick = "var _form = document.getElementById ('EditView ')) SUGAR.ajaxUI.submitForm (_form); false를 반환; " (287, 20)에서 type = "submit"name = "button"value = "Save"id = "SAVE"> 클릭 할 수 없습니다. 다른 요소는 다음과 같은 클릭을 받게됩니다.

+0

코드를 변경했으나 다른 오류가 표시되었습니다. @ navegador.find_element (: xpath, "/ xpath,"/ * @ title = '저장'/click [@title='Save']").click 알 수없는 오류 : 클릭 할 수 없습니다. –