I am using JWebUnit + HtmlUnit to functional test the webpage.
I currently encounter one problem that some dynamic added dom with content
provided by async calls from OnDomReady are not visible to the testscript.
the getPageSource() does not show these doms. More interesting, loading IE7
or firefox for the same page, by clicking "View Page Source", these doms are
not presented either, however, firebug and IE developer Tool can show these
elements without problems.
Any idea how to solve this issue using HtmlUnit?
Thanks
Eve Sun
--------------
The javascript on that page is like below:
YAHOO.util.Event.onDOMReady(function(){GenreAlbums.init();});
var GenreAlbums = {
ul : null,
url : null,
args : null,
sortLinks : null,
init : function() {
this.ul = YAHOO.util.Dom.get('genreAlbums').getElementsByTagName('ul');
this.sortLinks =
YAHOO.util.Dom.get('genreSortToolbar').getElementsByTagName('a');
for (var i = 0; i < this.sortLinks.length; i++) {
YAHOO.util.Event.addListener(this.sortLinks[i],'click',GenreAlbums.checkActiveLink,this.sortLinks[i],true);
}
this.getNewReleases();
},
getAsync : function() {
var params = 'genreId=g.6';
var connection =
YAHOO.util.Connect.asyncRequest("POST",this.url,{success:function(res){
GenreAlbums.callback.call(null,res,GenreAlbums.args);
}},params);
},
getNewReleases : function() {
this.url = PAGE_CONTEXT + '/listNewReleasesForGenre.html';
this.callback = GenreAlbums.drawAlbums;
this.getAsync();
},
drawAlbums : function(res) {
GenreAlbums.clearData();
var obj = eval("(" + res.responseText + ")");
for (var i=0; i < 12; i++) {
if (obj.albums[i]) {
var albumImg = new
Element('img',{'src':obj.albums[i].imageUrl,'alt':obj.albums[i].name});
var albumLink = new
Element('a',{'class':'albumimg','href':'/cinnamon-snapshot/album/album.html?albumId='
+ obj.albums[i].id}).update(albumImg);
var li = new Element('li').update(albumLink);
var albumNameLink = new
Element('a',{'href':'/cinnamon-snapshot/album/album.html?albumId=' +
obj.albums[i].id}).update(truncate(obj.albums[i].name,16,true));
var albumName = new
Element('span',{'class':'albumname'}).update(albumNameLink);
var artistNameLink = new
Element('a',{'href':'/cinnamon-snapshot/artist/artist.html?artistId='
+ obj.albums[i].artistId}).update(truncate(obj.albums[i].artistName,16,true));
var artistName = new
Element('span',{'class':'aritstname'}).update(artistNameLink);
li.appendChild(albumName);
li.appendChild(artistName);
li.appendChild(GenreAlbums.createAlbumRollover(i));
GenreAlbums.ul[0].appendChild(li);
}
}
},
}
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users