SJAX: AJAX option for automated in-browser testing
Written by on January 26th, 2007 in Ajax News.
Vitaliy Shevchuk has proposed SJAX: AJAX option for automated in-browser testing which makes testing of Ajax apps simpler with Selenium that having to waitForAjax and friends.
The Problem
However, things are getting more complicated with AJAX. No page is loaded, but the content has changed. And it hasn’t changed instantly; AJAX is asynchronous by its definition. Setting a bug interval is a bad solution: it makes build cycle very slow without really solving the problem.
Some guys suggest using a “waitForCondition” command. In other word, every time AJAX is in action you need to manually add a waiting condition. This is much better then nothing; at least it is a real working solution. However, test creating is much longer and less fun.
Another option would be to extend Selenium to make it aware the underlying AJAX framework, so that the test case would pause until XMLHttpRequest is satisfied. Well, it requires extending Selenium, which is not very simple task neither. And there is a multitude of AJAX frameworks available, it would be impossible to adapt Selenium to every of them. And there are other in-browser testing solutions, not only selenium: both open source and commercial ones.
Solutions?
And the ideal scenario would be the following:
- Test, application itself or the in-browser testing framework raises a flag to mark the current session as the one of automated testing.
- AJAX framework detects the flag and passes to synchronous mode.
- In this case, a method of user action simulation (click/type) of Selenium will not return until the AJAX data is successful fetched and processed. So Selenium will not be able to continue before the page content is updated, and it’s exactly what the user expects from his macros.
Source: Ajaxian
Original Article: http://ajaxian.com/archives/sjax-ajax-option-for-automated-in-browser-testing