selenium的BUG??selenium中启动IE进行测试,在js代码中如果有window.open()函数出现的问题,急救啊!
最近用 java写了一个用selenium测试WEB页面的程序,启动测试的浏览器选择为IE,
在javascript代码中如果有window.open()函数,则会出现问题,如下:
java程序启动selenium如下:
protected DefaultSelenium sele;
protected void setUp() throws Exception
{
try
{
sele = new DefaultSelenium("localhost",4444, "*iexplore", "http://localhost");
sele.start();
}
catch(Exception e)
{
logfile.writeLog(ERROR, e.getMessage());
}
}
在输入密码后,点击登陆按钮的代码如下:
sele.type("password", strPwd[i]);
sele.click("loginout_OkButton");
这时,在被测试WEB页面的js代码中关于点击按钮后的处理如下:
var w =screen.width - 10;
var h = screen.height - 60;
win = window.open("./framework.html?sessionId="+sessionid+"&userName="+useName.value , "cgpWin" + Math.round(Math.random()*10000), "height="+ h +", width="+ w +", top=0, left=0, toolbar=no, menubar=no, scrollbars=no,resizable=yes,location=no, status=no") ;
if (!win)
{
window.alert("Your browser has prevented popping-up the new window, please check its setting.");
}
else
{
win.moveTo(0,0);
win.resizeTo(screen.availWidth, screen.availHeight);
setTimeout('closeWin()',1500);
}
selenium在运行sele.click("loginout_OkButton")后,测试的页面总是会弹出“Your browser has prevented popping-up the new window, please check its setting” 的提示信息,window.open()打开新页面失败。但是如果直接打开IE,点击登陆则
可以打开新页面,同时,如果selenium启动firefox进行测试也可以打开新页面。这是怎么回事啊 ??跪求大家帮忙!!