Quality Testing

Quality is delighting customers


Is selenium tool supports ajax applications? If not please suggest me any open source tool.


Views: 226

Reply to This

Replies to This Discussion

Hi Kamali,
I really dont have used Selenium tool, but I do know that Selenium along with Ruby on rails/Ruby does recognizes Ajax application.
Also you can use Ruby + WATIR as an open source tool to get the AJAX controls identified.

Thanks Shirish.
Kamali, I think Selenium Tool doesn't support AJAX applications.

Selenium doesn't support AJAX.

Better to use Selenium on Rails.
Hiya Kamali,

Short Answer:

Yes, you can test Ajax driven web page content using Selenium IDE commands – the simplest way is to use the waitFor.. commands.

Don’t fall into the trap of putting pauses in between commands and asserts in the hope content has loaded though. This will see scripts breaking like crazy. Instead you can use the waitFor... commands and assign it to the value of whatever Ajax content you’re waiting for. The commands check every second for the content to appear before progressing with your script. For example you could have a waitForValue and assign it to the value of a second drop-down menu.

Long Answer:

However, (you knew that was coming...) it’s not straight forward. Let's take the example of Ajax driven drop-down menu options and look at it more closely. Goto www.lastminute.com and on the right hand side search panel select 'Car Hire'. Then hit the drop down for 'pick up location’. Nothing there right? We need to have selected a destination country before the pick-up list is populated and then a pick-up location for the drop-off location to be populated.

While we might usually try to cycle through the destinations (in this case) using say select as we know that will pull the Ajax content in and then use commands such as assertValue we're going to hit issues pretty quick with that approach. Have a look at the attached IDE script ajax_001 for an example. I bet running it at full speed causes it to crash on step 3, where the script tries to select the pick-up location. The Ajax options haven't loaded, hmm. You could slow the test runner down but by how much? What if the site loads slower next time or your internet connection is suffering lag? This is too brittle an approach to use. The same problem exists if you try to put a pause in between commands too and that goes for selectAndWait on anything but the first option as the page isn't being refreshed and the IDE won’t ‘see’ your new drop-down menu options becoming available.

What we have in the IDE now are a whole bunch of waitFor... commands that will wait for a something-we-specify before the script progresses. A useful option for our test here would be waitForValue so we can wait for a new value to be present in the pick-up location drop-down once we’ve selected ‘alicante’ as a country in the destination drop-down. (Alicante = country!?). But hang on, when we do that there’s no new value presented, it just stays as ‘select a location’ so waitForValue isn’t going to work here either. This isn’t a Selenium IDE issue it’s more a design-for-test(automation) issue and something to chat with the development team about.

Just to confuse things try this: select ‘alicante’ as the destination and ‘alicante airport’ as the pick-up location. Did you notice that the value in drop-off just changed. Arrgghh, etc. etc. though I ‘get’ it from a design point of view it’s simple things like this that give testers automation headaches. At least we can use our waitForValue command here though :) Have a look at the attached IDE script ajax_002 script to see how it might look.

There are no pauses in the script as we’re looking to use the commands that are effective without having to ‘pad’ them.
1) We do a selectAndWait on the first option which is the destination.
2) Then a straight select on the pick-up location followed by an assert. It would be best to do a waitForValue but nothing’s visible to the IDE.
3) We then do a waitForValue on the drop-off location to hold the script until our new Ajax options are available,. This is preferable and we can do it as the fist (visible) option changes.

As you’d expect there’s a number of ways to go about this and my preference is to use Selenium commands with Ruby. That way I can programmatically check when the Ajax is in the page more easily. Have a play and let me knpw if you have any other issues.

Final shameless plug, this is covered in much greater detail in the book I've written; "An Introduction to Web Test Automation with Selenium & Ruby", which I'm currently touting to publishers.

Ooops, here's the IDE scripts I mentioned in my reply above.

That is very informative .
I really appreciate your time for such a descriptive explanation on using Ajax :) Mark.

Yes, Selenium web driver is capable of testing the ajax enabled web applications.

Most of the Web Applications are using AJAX these days to make web applications more dynamic in nature and AJAX stands for Asynchronous JavaScript and XML, AJAX helps web applications to load small chunks of data from the webserver without having to refresh the complete page.

When it comes to automated testing of ajax elements, there are some challenges associated with it like whether the Ajax call has been completed & the page has been updated. Sometimes the required information may load within a second & somethings it can take much longer.

So most qa software testing company professional uses the explicit wait depends on the actual scenario requirements.

However, we can build a custom library to handle the synchronization.

Here below if the Java file for the same containing the same: Synchronization_WAIT.java

Test Script using the above library: TestScript_Wait.java

Please do let me know if there's any doubt.



TTWT Magazine





© 2020   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service