Reputation: 171
I need some Guidelines for writing selenium automation scripts in java
I have identified the following
1) Put relevant comments 2) Surround code with try/catch 3) Don't repeat code 4) Split code into short focused units 5) Be consistent
Please suggest if there are any more. Thanks
Upvotes: 0
Views: 146
Reputation: 171
These are some of the links I have found for Guidelines
http://www.techbeamers.com/java-coding-guidelines-coding-style/#java-exception-handling
Upvotes: 0
Reputation: 166
Try catch might be useful in test framework code, but try to avoid using it in the tests itself.
In general, if there is a condition in your test that throws an Exception, then you want your test to fail with that specific Exception. I.e. if we have a scenario that includes logging in and the login button is not present, then we want to fail it straight away on the failed click of the login button. Ignoring the failure and continuing is pointless.
There can also be situations where the application under test is unpredictable. You can sometimes make constructions with a try catch and a retry to get the test to pass consistently. However, it is still preferred to talk with a developer to try to get the behavior of the application under test more predictable. In this way you can keep your tests simpler and understandable and every time it is run you are really testing the same thing.
Upvotes: 1