Start automation with no Selenium knowledge with our Record & Replay tool using these Best Practices.
Note: Record and Replay is under active development – we try to keep this document up to date, but we make changes to the product faster than we change the documentation. Feel free to give it a try and let us know how it goes!
Record Explicitly, and with Intention
The recorder (and Selenium) needs very specific instructions on what to execute. Record as if you were explaining to someone over the phone what you want them to do. Here are some examples about being explicit:
- Hover over a word to reveal a menu. Add a hover step so our recorder knows when to hover and what to hover over.
- Wait for the page to load. Add a sleep if your page takes a while to load or a specific element only appears after some amount of time.
- Scroll down until a button appears. When you scroll, we will record the scrolling. Make sure the scroll brings the element into the frame completely so our recorder knows how much to scroll to see the button.
Remember to be intentional about your steps. Record & Replay is a very powerful tool for making sure must-have functionality works on your site. If you are doing exploratory testing, this may not be the best tool for that.
Developing with Unique Elements for Record Targeting
The Recorder works best when your website is developed with the most modern web standards. Here is a quick list of recommended patterns to follow. The Recorder is looking for the most unique CSS Selector to target when building your script. The more unique & simplistic your CSS selection path, the more reliable your script will be on Playback.
- Unique Element Ids: W3 docs
- Unique Input Names: W3 docs
- Unique Button Text: W3 docs
- Targeting Nested (child) Elements: CSS Tricks
Recording your Script
- Don’t close tabs during recording session.
- Clean up & Remove any extraneous/accidental clicks or scrolls.
- Input Fields Click input fields before entering text – instead of using the tab Key to switch element focus.
- Form Submit Click submit button instead of pressing enter to submit forms.
- Adding Hover: Exposing elements under a CSS :hover (pseudo class), use the Add Hover step instead of using the cursor.
- Basic Auth – URLs protected by Basic Authentication are unsupported by Selenium, and therefore unsupported by our recorder. Though you may be able to enter username/password on recording, the credentials are not stored nor can be replayed in your scripts.
- CAPTCHA – Forms with this security feature will fail on replays. It exists to prevent bots and your replay is exactly what it is intended to stop.
- CSS Transformations – If you use CSS transformation to apply capitalization, some browsers will fail on replay as they look at the HTML and it is case-sensitive. Future support is planned.
- When clicking or adding an expect to an element, keep the element in the browser viewport.
- Avoid Testing Dynamic or Random generated content.
- Try switching elements in our Edit mode if the replay fails
- When using Replay, try not to change resolutions as elements may no longer be visible.
Here are a list of tools/exercises that will help you understand CSS Selectors when developing:
- CSS Diner Game – Test your skills!
- Evaluate and validate XPath/CSS selectors in Chrome Developer Tools
- developers.google – Test Selectors in Chrome Dev tools: