0

I use Serenity (Thucydides) + Cucumber to test web application in Chrome browser. I want to verify if some elements exist on the page.

Scenario Outline: Should see six tabs on the page
    When I am on MainPage page
    Then I should see the following <tab> as tab:
    Examples:
      | tab         |
      | Tab_1       |
      | Tab_2       |
      | Tab_3       |
      | Tab_4       |

I successfully verify the first tab, but cannot verify the other tabs as the page reloads after the first iteration. How to stay on the same page? Is it managable in my case?

Verhagen
  • 3,885
  • 26
  • 36
Alex
  • 362
  • 1
  • 5
  • 14

2 Answers2

0

Scenario Outlines create a seperate scenario for each example element. You want a single scenario that looks for your tabs.

A better way to write this would be to name the tabs, e.g. foo-tabs and then write

Scenario: See foo tabs on main page
  When I am on the main page
  Then I should see foo tabs

And in your step definition do your programming to look for the tabs e.g.

Then "should see foo tabs" do
  foo_tabs.each do |tab|
    expect(page).to have # do something with the tab here
  end
end

(above is ruby'ish code, but you should be able to adapt to java)

Now you will have one scenario, and also if you add/remove a tab, you won't have to change your feature.

diabolist
  • 3,990
  • 1
  • 11
  • 15
  • Yes, I know how to check separate element, I want my code in feature file and the test report to look more readable, so I use table data in the Scenario Outlines. My question was and is how to prevent the page from reloading. – Alex May 20 '15 at 07:05
  • I see that after each step the page set up with @DefaultUrl is open. So I should somehow manage it? – Alex May 20 '15 at 07:44
  • 1
    I've shown you how to make your feature more readable. You can't get around the way Scenario Outlines work, they create a seperate scenario for each thing in the example group. If you continue to use an outline you will not resolve your issue. – diabolist May 20 '15 at 17:40
  • I appreciate you comments. But Scenario Outlines work for me pretty well now. – Alex May 21 '15 at 07:58
  • @Alex I know this is old, but how did you solve this? – juliangonzalez Nov 09 '18 at 18:10
0

I used Before fixture incorrectly. I've solved the issue by set up Global Hook BeforeAll.

Alex
  • 362
  • 1
  • 5
  • 14