Once we know the business layer is sound, we can test the presentation layer too.
Presentation - Test Driving Web Development
How does Selenium IDE fit into an overall testing strategy? What does Selenium actually do? How does it work? Can Selenium help simplify testing? Are there any best practices?
We explore and install a popular testing tool called Selenium IDE.
- Testing MVC
- How Selenium Works
- Simplifying Test Scripts
- Best Practices
Workshop - Menu
Story: Subscribers can select available tasks from a list, including edit Profile and Logout.
- Create a menu page for registered users
- Utilize Struts tags to display user's name
- Create a Selenium IDE tests to prove the menu page works!
- Install Selenium IDE add-on for FireFox
- Utilize Canoo WebTest to verify navigation within the application.
- property tag
- "chain" result type
- Selenium IDE concepts
- Review the Menu user case.
- Add a Menu.jsp to display the Edit and Logout tasks
- Include the user's name in the page
- Add a Menu action.
- On a successful registration, go to the Menu action.
- If your action did not utilize MailReaderSupport, try it again with class="MailReaderSupport"
- Install Selenium IDE into FireFox https://addons.mozilla.org/en-US/firefox/addon/2079
- Record test that Register's Trillian with the application
- See Register user case for sample data
- To reset database after a test run, open Debug perspective, and from the Servers view, stop, clean, and start Tomcat
To show the newly registered user's name, use the property tag on the Menu page.
<h3>Main Menu Options for <s:property value="fullName"/></h3>
And "chain" to the menu page from the Register_save action.
<action name="Register_save" class="Register" method="save"> <result name="input">/pages/Register.jsp</result> <result type="chain">Menu</result> </action>
As to Selenium IDE
- Change the default Web Browser in Eclipse (under Windows), or open FireFox separately after starting the Server
- Open Selenium IDE under FireFox Tools
- Change the Selenium IDE Options to "Record AssertTitle automatically"
- When playing back and editing a test, turn the recorder off (toggle round red button "up")
- When a clicking on a control changes the page, change "Click" to "ClickAndWait"
- Created menu page with dynamic elements
- Utilized Selenium IDE to verify navigation within the application.
- Run the test again? Does it fail, as expected?
- Change the Selenium IDE mode from Run to Walk, and then to Step. What happens?
- Remember to reset the database in between test runs!
- Try running the test with the "Selenium Test Runner" (see button bar).
- Export the HTML script to Java, install Selenium Remote Control, and run the test under JUnit (if you dare!)