We will help test out a survey hosting site, http://checkbox.io
We will write unit tests using Selenium that verify the following: http://checkbox.io/studies.html
- The participant count of "Frustration of Software Developers" is 55
- The total number of studies closed is 5.
- If a status of a study is open, you can click on a "Participate" button.
- Check if the "Software Changes Survey" has a Amazon reward image.
Solution
-
The participant count of "Frustration of Software Developers" is 55
Logic:- Search for the span containing text "Frustration of Software Developers".
- Go to the parent of parent of this span.
- Go to "span4" class which has "backers" class span.
- Check if the text in this span is "55".
-
The total number of studies closed is 5.
Logic:- Find all the "status" classes of
a
tag. - From these make a list of all the spans that contains text "CLOSED".
- Check if the list size is 5.
- Find all the "status" classes of
-
If a status of a study is open, you can click on a "Participate" button.
Logic:- Find all the "status" classes of
a
tag. - Find all the spans that contains text "OPEN".
- Go to parent of parent of these spans.
- From these make a list of all button elements of button class "btn btn-info".
- For each button, check if it is enabled.
- Find all the "status" classes of
-
Check if the "Software Changes Survey" has a Amazon reward image.
Logic:- Find the span conatining text "Software Changes Survey".
- Go to the parent of parent of this span.
- Go to div class "award".
- Find
img
tag in this division. - Check if the image source of this tag is the Amazon Award Image source by checking it's reference to http://www.checkbox.io/media/amazongc-micro.jpg.
The code for the above unit tests can be found in Selenium/src/test/java/selenium/tests/WebTest.java
.
To Run the code:
- Import Selenium project.
- Run WebTest.java to see the test cases running.