2017-01-20 6 views
1

오이와 루비를 사용하여 자동화하고 있습니다. 내 시나리오는 다음과 같습니다.오이에서 개별적으로 두 단계 정의를 구현할 수 없습니다.

Given I'm on home page 
When i click on links 
Then it should redirect to corresponding pages. 

구현하려면 두 번째 단계에서 모든 링크를 클릭하여 반복했습니다.

이렇게하려면 매번 홈 페이지로 돌아가서 확인해야합니다. 매번 두 번째 단계 구현을 반복해야합니까? 아니면 세 번째 단계를 건너 뛰고 두 번째 단계 자체에서 모든 것을 구현할 수 있습니까?

Background: Member should open homepage 
     Given member goes to home page 

    @javascript 
    Scenario: Member should go to correct url by clicking links in head menu 
    Then member should ensure that links in the table go to correct url 
     | Spor Giyim   | /spor-giyim   | 
     | Kadın    | /kadin     | 
     | Erkek    | /erkek     | 
     | Ayakkabı & Çanta | /ayakkabi-canta  | 

루비 부분은 다음과 같이해야한다 :

Given I am on home page 
When I collect a list of links and the text from the header menu 
Then visiting each link should return a page where the title matches the link text 

:

When(/^member should ensure that links in the table go to correct url$/) do |table| 
    # table is a Cucumber::Core::Ast::DataTable 
    links = table.raw 

    links.each do |line| 
     link  = line[0] 
     target_url = line[1] 

     click_link(link) 

     url = page.current_url 
     expect(url).to include target_url 
    end 
end 

답변

1

은 다음을 참조 또는 대체 텍스트와 일치하거나 해당 URL의 URL과 일치하는 항목 일 수 있습니다. 위의 명령형 접근 방식은 페이지에 추가 된 새 항목이 확인되지 않도록하고, 떨어지는 것이 확인되는지 확인합니다.

더 긴급한 목록을 만들고 싶다면 링크 만 표시되고 예기치 않게 새 링크가 표시되면 오류가 발생하는지 확인합니다.

+0

감사합니다. 지금 해보 겠어. – Rohin

+0

@Rohin은 대답을 수락하기를 바랍니다. –

1

나는 약간 덜 필수적 접근 방식을 좋아하는 당신은 테이블에서 할 수있는