|
最近刚刚开始学习selenium,由于产品系统使用了window.open的javascript代码导致启动时候的窗口无法识别,描述如下:
例如我的启动窗口时 http://192.168.0.111:8080/ 这个页面会指向一个主页面,在主页面的代码里有一条 window.open的语句。它主要做如下工作,新打开一个带window name的窗口,然后关闭 http://192.168.0.111:8080/ 指向的页面。 我在selenium中就无法获取到新打开的窗口了,导致出现如下错误(注:我在FIRFOX里通过selenium.selectWindow可以用,但是在IE就会报下面的错误.)
undefined com.thoughtworks.selenium.SeleniumException: Timed out after 30000ms
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:335)
at AUT.seleAUT.testUntitled(seleAUT.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
从selenium IDE中能够抓到 selenium.selectWindow("name=xxxxx")
但是这段代码加入到执行脚本中还是无法获取窗口,请各位老师帮忙解决下
javascript 如下
window.open("about:blank","mytest",toolbar=0,location=0...........................)
setTimeout(openLogin,100);
function openLogin(){
window.open("/login.jsp","mytest",toolbar=0,location=0...........................)
window.opener =null;
window.open(' ','_self');
window.close();
}
注:如果通过watij可以解决,也请告知谢谢了。
[ 本帖最后由 lbb520 于 2010-7-26 14:22 编辑 ] |
|