In order to make it easier for developers to write their Selenium tests, I created an extension to user-extensions.js in Selenium to do the logon for them if needed or go directly to the application home page.
I determined that you are on runtime (hence logon is required) if you are in HTTPS. Anyway here is the code:
/**
* doCuramLogon
* @param username
* user name to logon as. Defaults to "superuser"
* @param pageID
* page ID to go to. Defaults to "Application_home"
*/
Selenium.prototype.doCuramLogon =
function(username, pageID) {
if (!username) {
username = "superuser";
}
if (!pageID) {
pageID = "Application_home";
}
if (this.page().getCurrentWindow().protocol ==
"https:") {
this.doOpen("/Curam/j_security_check?" +
"j_username=" + username +
"&j_password=password");
} else {
this.doOpen("/Curam/en/" + pageID +
"Page.do");
}
};
The toughest part was figuring out how to do the logon. After Googling a bit I hit this
page which specifies in a nutshell that Selenium user extensions cannot perform methods that would span more than one page. So
this.doOpen would not pass the context correctly to the next commands. Hence j_username cannot be found whenever I do a doOpen().
The next tough part was trying to get this thing working in Selenium IDE which returns the location.protocol as "chrome:"
One note, when using this, you have to specify
curamLogonAndWait as the command to make sure it waits for the page to load.