Web UI Testing with Java/Selenium -

Astronomy Picture of the Day Search Page

Feature File

Look over the page: https://apod.nasa.gov/cgi-bin/apod/apod_search

There are two buttons. Let's test them both.

Feature: APOD Search Tests
I want to test the functionality of the buttons on APOD's search page

We're always going to start from the search page, so this can be written as Background in the feature file:

Background:
Given I am on the search page

One of the buttons is called "Clear the form." Let's test that first. We'll need to enter text and then clear it.

Scenario: Test "Clear the form" button
Given I have entered text in the search box
When I click "Clear the form"
Then the text in the search textbox should disappear

For the search button, let's run multiple tests with different text entered. To do this, we'll use a data table and a Scenario Outline:

Scenario Outline: Text search test
When I enter <searchtext> in the textbox
And I click "Find the words"

Note Use the exact same wording on the "click button" line as you did above. That way you'll only have to code it once. The feature file will supply the name of the button (as long as you put the name in quotation marks). Using "And" instead of "When" is fine, as long as the "And" is following a "When."
Then I should be taken to a results page
And <searchtext> should appear somewhere on that page

Follow with a data table. You can put whatever you want for the variables. Just make sure the header matches the placeholder used above:

Examples:
| searchtext |
| "Orion Nebula"|
| "supernova" |
| "eclipse" |

That's it! Your feature file is ready. Back to tutorial.

-- SummerDale - 04 Sep 2020
Topic revision: r1 - 04 Sep 2020, SummerDale
© 2020 Ultranauts - 75 Broad Street, 2nd Floor, Suite 206, New York, NY 10004 - info@ultranauts.co