[求助]Selenium处理ModalDialog并submit返回主界面
由于Modal dialog会挂起JS,所以通过window.open重写showModalDialog方法,但是在window.open时,无法将主界面的parentid传递给新的window,所以,在新的window中,点解submit的时候,会找不到主界面。通过window.open有没有办法把主界面的parentid传给新的window呢?
下面是重写showModalDialog的方法:
private voidclickForModalDialog(Selenium selenium){
String overrideShowModalDialogJs = "if(selenium.browserbot.getCurrentWindow().showModalDialog){";
overrideShowModalDialogJs += "selenium.browserbot.getCurrentWindow().showModalDialog = function(sURL, vArguments, sFeatures){";
overrideShowModalDialogJs += "selenium.browserbot.getCurrentWindow().open(sURL, 'modal', sFeatures);";
overrideShowModalDialogJs += "};}";
//showModalDialog方法进行覆盖
selenium.getEval(overrideShowModalDialogJs);
selenium.click("link=New Group");
selenium.waitForPopUp("modal", "15000");
selenium.selectWindow("modal");
}
页:
[1]