We have selenium scripts (say around 20 scripts). When we run all the 20 scripts some how 3 or 4 scripts going to fail but when I run the same script it is going to pass. I don't understand whether I am doing something wrong or if there is any different approach to run multiple scripts. Please help me

closed as unclear what you're asking by IAmMilinPatel, ECiurleo, testerab Feb 4 '16 at 0:54

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What issue are you getting? What exceptions are coming in these failed tests? – demouser123 Jan 29 '16 at 8:11
  • What exceptions are coming in these failed tests? and with framework you used to run the 20 cases.?(TestNg/Junit) – Ishwar Dharmadhkari Jan 29 '16 at 8:48
  • different issues like "ElementNotFoundException","ElementNotClickable" etc.., – QAMember Jan 29 '16 at 9:59
  • different issues like "ElementNotFoundException","ElementNotClickable" etc.., – QAMember Jan 29 '16 at 10:00
  • I am using testng frmaework to execute all those 20 test cases – QAMember Jan 29 '16 at 10:01

We have a bunch of selenium test cases and could observe a similar behavior. We dug into the issues and figured out two things:

  1. Make test cases "orthogonal"

Test cases should not depend on each other. But that also means that every test case is responsible for creating the correct precondition for itself to run. Don't make any assumptions about the environment, e.g. always create fresh empty database tables before running a test case.

  1. AJAX is a bit trickier to test

When You are using jQuery / JavaScript on Your site You have to make sure that the asynchronous code is already executed when you make a check In Selenium you can either wait directly or wait for a specific elements to appear on the site. You also can inject script code e.g. focus on other element to ensure that the async action is triggered.

For more specific advice some samples of you testcode is needed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.