Based on the answer from Daniel Wagner, I have created the following abstract base class for our simulator tests. The method access the iframe, fill out the form, and submits the from to the server and wait for the success response.
qx.Class.define("app.simulation.AbstractSimulation", {
extend: simulator.unit.TestCase,
type: "abstract",
construct : function () {
this.base(arguments);
this.baseLocators = {
loginWindow : "qxhv=*/[@classname=app.window.system.Login]",
startPage : "qxhv=*/[@classname=app.lib.ui.widget.StartPage]"
};
},
members: {
__loginDone : false,
/*
---------------------------------------------------------------------------
TESTS
---------------------------------------------------------------------------
*/
_loginToApp : function(user, password)
{
if (this.__loginDone) {
return;
}
var loginToApp = 'function(user, password) {'
+ 'var iframe = selenium.qxStoredVars["autWindow"].document.getElementsByTagName("iframe")[0];'
+ 'iframe.onload = function () { '
+ ' var innerDoc = iframe.contentDocument || iframe.contentWindow.document;'
+ ' innerDoc.getElementsByName("username")[0].value = user;'
+ ' innerDoc.getElementsByName("password")[0].value = password;'
+ ' innerDoc.getElementById("submitbutton").click();'
+ ' };'
+ '};';
this.getSimulation().waitForWidget(this.baseLocators.loginWindow);
this.getSimulation()._addOwnFunction("loginToApp", loginToApp);
var functionCall = 'selenium.qxStoredVars["autWindow"].qx.Simulation.loginToApp(\"' + user + '\", \"' + password + '\")';
this.getQxSelenium().getEval(functionCall);
this.getSimulation().waitForWidget(this.baseLocators.startPage, 30000);
this.__loginDone = true;
},
/**
* Login with Root User
*/
loginToAppWithRoot : function ()
{
this._loginToApp("root", "root");
}
}
});