| || |
Answer to fewer lines of selenium codes?
I am working in a e-commerce web store. Till the moment I have around 16 tests, each ranging from 150 to 450 lines of code.
I am looking forward for a way which will help me to reduce lines of selenium codes. Yes, I have managed to come up with some methods which I can reuse over several test classes. Still, at times I am struggling with the size of tests. Maintenance becomes nightmare at times.
I am facing a challenge to come-up with a framework of my tests, which will separate stuffs. But what & how should I separate things, and what can be those things?
I am seeking light from them experts who have played around this kind of scenario.
Re: Answer to fewer lines of selenium codes?
As you mentioned you are writing methods..it is good to further make ur scripts better..
If you have e-commerce appliation with below modules or pages:
Create a class file for each of above and write methods for each functionality in the module, also try to put all native selenium code which has locator, xpaths here for better maitainence. (This can go to any number of lines [img]/images/graemlins/smile.gif[/img], but your main test scripts will have less number of lines) - OOPS
Store Test Data in properties file or xml
When you start creating scripts for the test cases, say for MyProducts there are 5 tests.
for each test
1. Create an instance of all the clases you are in need of like Login, MyProducts, Logout
2. Write scripts and validate them expectected vs. Actual. (keep you tests simple)
3. If you have any prerequisites then use SetupMethod & clear them in Teardown.
U can use existing frameworks, TestNG-Hudson or JUnit or other unittest frameworks.