Be it load&performance testing, be it unit-testing, it seems that all related tools have some problems with JSF’s dynamic ID-attributes.
With dynamic ID I want to indicate that the ID of a certain input-field or a button/link can change if
- no fixed id is specified (id=…)
- the page-structure changes (eg. conditionally rendered components in templates)
- real page-changes (new requirements, refactorings)
I would say a testable JSF web-application has fixed ID’s for all input- and command-components. Pure output-components like h:outputText do not need a fixed ID.
So far this is the most important testability-criteria. Of course most things can be done otherwise. But it sure is more hassle. The load&performance test-tools are more dependent on the ID-attribute because it determines also the NAME-attribute. I consider the better testability more important than the minimal time-saving by not specifying the ID-attribute.
Hi Ajesse,
I’m currently using Selenium RC for performance test in JSF pages, but I have two problems to use it. Could you help me?
1. in rich:modal dialog, after click a ajax behind checkbox, the dialog don’t render,
seleHelper.waitElementPresent(“blahblahPerformance:1″);
I have tried several method, but failed
1 try to pause(10000) after click the ajax component
(x)no response
2 try to waitForPageLoad
(x)no response
3 try to waitElementPresent
(x)no response
4 try to while(true) + waitForCondition + isElementPresent
(x)no response, while loop will not end
5 try to modify selenium-api.js, and use isElementPresentOrNull
(x)still no response
2. also in rich:modal dialog, after click the , it cannot call blah, so bloked the main workflow.
JSF page:
java code
seleHelper.clickElementByXPathIdNoWait(“btnAddEvent”);
seleHelper.waitElementPresent(“blahNameNeedRefresh_the_parent”);
seleHelper is an instance of my helper class.
in my helper class:
public void clickElementByXPathIdNoWait(String id) {
selenium.click(getXPathStringById(id));
}
private String getXPathStringById(String id) {
return “xpath=//*[contains(@id,':" + id + "')]“;
}
public void waitElementPresent(String id){
String xps = getXPathStringById(id);
StringBuffer sb = new StringBuffer();
sb.append(“selenium.isElementPresent(\”");
sb.append(xps);
sb.append(“\”);”);
waitForCondition(sb.toString());
}
public void waitForCondition(String script){
selenium.waitForCondition(script, timeout);
}
Thanks very much
Comment by cronzhong — September 28, 2008 @ 7:23 am |
Unfortunately not. So far I have successfully worked against AJAX. I just do not believe there is need for such a thing in a web-application. That means also, that I never have to test AJAX-stuff.
Isn’t Richfaces from JBoss? Then JSFUnit might your ticket for a successfull testing-story. They have explicit support for RichFaces.
Comment by ajesse — September 28, 2008 @ 3:20 pm |