To use direct page URL or complete path?
My question is which approach is recommended when writing automation test for testing something like filters present on page no.3?
- Should I directly use url of page no.3 in my test file and test filters on the same page. Or
- Use complete path like open home page , click some button to navigate to page no.2 and then navigating to page no.3 by clicking any link.
Should I mimic real user experience like whole path or jus url because I already have test scripts written for page no.1 and 2 ?
Thanks in advance.
Mystic last edited by
Like a lot of things in life, it depends.
Both options you lay out will work for test automation. However, what is your overall goal?
Are you testing a feature that is on one page? If so, you can load that page directly and test that feature. This is what you listed as option 1.
Are you testing a feature integration point, like a page redirect? Are you testing an end-to-end user scenario? For these, you'll want start at a beginning point and test from there. This is what you listed as option 2.
Ultimately, you'll probably end up with a mix of these solutions. Some questions to consider are:
- How much setup do you have to do before the filter is applicable?
- What is the intent of the filter while considering end-to-end scenarios?
- How fast do you want your tests to perform?
For example, if you're testing a travel site and want to book a plane ticket for a specific airline, then option 2 is the better option, since you have to setup a departure date/time, starting airport, ending airport, etc. Once the applicable results are loaded, then you can filter per airline.
If you're testing an ecommerce site and you want to filter a category by a sub-category, option 1 would be better, since you most likely will know the direct url for the main category page without having to use a search query or menu navigation to get there.
It really depends on your context and what your test is attempting to assert.