Hi Anand,
1. short answer:
- RF is consistent
- Your testcases are faulty
2. long answer:
In the wonderful world of dynamic HTML, JavaScript, AJAX, etc. web content in the browser is not static any more, but very often generated on the fly. Furthermore there is no control of the timing of events or durations of actions.
Example:
In our application all buttons are most of the time simple images. First when the mouse pointer enters a button the element gets removed and replaced by a clickable button with a slightly different image. If you use now simply the keyword Click Element on such a button, you have exactly such a unstable behavior. Why? Because Click Element has to do internally two things. It moves the mouse pointer over the button and then immediately clicks the button. Now look at the timing:
When the testcase calls Click Element the following happens:
- Your testcase moves the mouse over the button.
- After some milliseconds in the browser the onEnter event-handler gets called.
- The event handler removes the dummy button, adds the real button, makes the new button visible, enables the new button
- Parallel your testcase clicks on the button.
Depending on the timing of the click the following could happen:
- The click gets executed, before the dummy element is removed:
No failure is logged, but nothing happens, because the button is a dummy. - The click gets executed, after the dummy element has been removed, but before the real button has been added:
A "Locator did not match any element" error occurs - The click gets executed, after the real button has been added, but before it is visible
A "Element not visible" error occurs - The click gets executed, after the real button is made visible, but before it is enabled
A "Element not clickable" error occurs - The click gets executed, after the real button is enabled.
It works as expected
In real life depending on browser, browser version, operating system, cpu load, network load, network latency, file system load and another thousand things you will see one of the five things happen. Some more often than others, but in the end it is non-deterministic.
Selenium 1 (RC) tried to fix that by introducing a default wait between every action. The hope was, that the browser finished all actions, before Selenium executed the next action. There were only two problem. First, increasing the wait times made the test execution awfully slow and second, there were always test executions where the wait was to short.
In Selenium 2 (WebDriver) all that sleep stuff was replaced by explicit waits on properties. So it is possible to wait fort all required actions to finish and to write deterministic testcases.
In our application we are using the following keywords to click on a button:
- Mouse Over <locator of the button>
- Wait Until Element Is Clickable <locator of the button with correct image>
- Click Element <locator of the button>
This works stable for our application.
I hope you understand now, why your testcases are faulty. From experience I can say there is no tool that saves you from understanding your system under test when you want to automate testexecution.
Hope that helps,
Markus