Creating a test case
Writing your own keywords
Understanding locators
Running your test
Introduction to understanding test structure
In order to start writing a test case - you will need to ask yourself a simple question; what are you testing? This can range between functional tests, acceptance tests, layout tests, user journeys etc etc.
From the post before this I have already outlined a test in such a way that we are following a users steps.
Lets refresh our minds on the test outline:
Go to google
Type in a search
Click the search button
Verify search page
This is probably as simple as it gets and should take 15-30 minutes max. So let us begin.
Preparations:
Ride installation
IE/Chrome/Firefox Installed
*optional but you should really work like this* A test directory containing a suite, repository, user keywords (see previous blog post)
A simple test case like this is easily written in one file - I will touch onto the user keyword file at the end of this post, and go into more detail as this series progresses.
In order to visualise the automated process, its best to perform the test manually to ensure you know robot can be driven through it:
Visualise:
Open RIDE, and open chrome at http://www.google.com
- you should see googles simple seach field + search buttons
Perform a search e.g wikipedia
- the page should automatically change presenting your search/you may need to also click the button
Verify that your word has been searched
- you can see that your searched word is still in the search box.
Now we know what to expect, we can start to get robot to do it for us. Obviously in a real test prep phase, you would not automate this test, however to make this lesson worth while, I will extend it with a user keyword.
Baby Steps:
Attacking the problem line at a time will help you in the long run!
Open RIDE with your test project, within the suite file (your main test case area) begin by writing
Performing a basic google search
Open browser http://www.google.com browser=chrome
This code should be runnable, it will open chrome and pass. We will need to input text into the search and click the button. Within your repository you will need to assign your locators to variables.
In order to find a locator you will need to open your browsers developer tool and use the element finder (the 3 browsers listed should have them)
At the time of writing this, the field has the id "gbqfq" and the button has the id "gbqfba"
Now that we have these, we can start interacting with them.
Continuing from our suite file
In order to find a locator you will need to open your browsers developer tool and use the element finder (the 3 browsers listed should have them)
At the time of writing this, the field has the id "gbqfq" and the button has the id "gbqfba"
Now that we have these, we can start interacting with them.
Continuing from our suite file
*** Test Cases *** Performing a basic google search Open browser http://www.google.com browser=chrome Input Text "wikipedia" id=gbqfq Click Button id=gbqfba | This will open chrome at google This will input wikipedia at the ID (text) This will click the button at the ID |
Note: press F5 at any time to see what keywords are readily available for you.
You should be able to run this test and you will be at the search page.
A good way to validate is to use the keywords "Page should contain" or "Element should contain"
There are many ways to implement it too for example: validate by knowing there is a h3 titles, search results, extra buttons - something that is not found on the original page.
Alternatively you can follow the test outline and validate by checking the text field (might need to check that the id matches) contains "wikipedia")
Your final code should look like this:
You should be able to run this test and you will be at the search page.
A good way to validate is to use the keywords "Page should contain" or "Element should contain"
There are many ways to implement it too for example: validate by knowing there is a h3 titles, search results, extra buttons - something that is not found on the original page.
Alternatively you can follow the test outline and validate by checking the text field (might need to check that the id matches) contains "wikipedia")
Your final code should look like this:
*** Test Cases ***
Performing a basic google search
Open browser http://www.google.com browser=chrome
Input Text "wikipedia" id=gbqfq
Click Button id=gbqfba
Page Should Contain id=resultStats
Performing a basic google search
Open browser http://www.google.com browser=chrome
Input Text "wikipedia" id=gbqfq
Click Button id=gbqfba
Page Should Contain id=resultStats
In this example i used the locator of the text field that indicates the time taken to perform this search.
Summary:
We have written our basic test which covers a basic acceptance scenario.
Coming Soon:
Using variables to store locators
Writing your own keyword to pass in strings for a locator.
Coming Soon:
Using variables to store locators
Writing your own keyword to pass in strings for a locator.