2017-05-09 8 views
0

後GEBとポップアップウィンドウを閉じる:は私がゲブテストフレームワークを使用して、以下を達成しようとしている警告

  1. 私は、ボタンの上に私をクリックし、ポップアップ・ウィンドウ
  2. を開いた
  3. アラートが発生しました
  4. OKをクリックすると、ポップアップが閉じられます。私はこのエラーを取得してい

    // open the popup by clicking the link (javascript) 
    withNewWindow({ selectLink.click() }) { 
        // doing some other stuff in the opened window 
    
        // closing the window by clicking a button 
        // Javascript will close the window after the alert is closed 
        withAlert {     // <- The error is raised here 
         $(".select").click() 
        } 
    } 
    

    org.openqa.selenium.NoSuchWindowException: Window not found. The browser window may have been closed. 
    Command duration or timeout: 15 milliseconds 
    Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46' 
    System info: host: 'dev1b', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-4-amd64', java.version: '1.8.0_92' 
    Driver info: org.openqa.selenium.firefox.FirefoxDriver 
    Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.7.0, platform=LINUX, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] 
    Session ID: 9b775683-e9c9-4651-a5fd-2c1f5e9fcb91 
    
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701) 
        at org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:511) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:498) 
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) 
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) 
        at org.codehaus.groovy.runtime.metaclass.MethodMetaProperty$GetBeanMethodMetaProperty.getProperty(MethodMetaProperty.java:76) 
        at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:64) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296) 
        at geb.report.PageSourceReporter.getPageSource(PageSourceReporter.groovy:42) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:498) 
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) 
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) 
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) 
        at geb.report.PageSourceReporter.writePageSource(PageSourceReporter.groovy:38) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:498) 
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210) 
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59) 
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174) 
        at geb.report.PageSourceReporter.writeReport(PageSourceReporter.groovy:29) 
        at geb.report.Reporter$writeReport.call(Unknown Source) 
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) 
        at geb.report.CompositeReporter.writeReport(CompositeReporter.groovy:31) 
        at geb.report.Reporter$writeReport.call(Unknown Source) 
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) 
        at geb.Browser.report(Browser.groovy:927) 
        at geb.Browser$report$8.call(Unknown Source) 
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) 
        at geb.junit4.GebReportingTest.report(GebReportingTest.groovy:37) 
        at geb.junit4.GebReportingTest.writeGebReport(GebReportingTest.groovy:60) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:498) 
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33) 
        at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:53) 
        at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55) 
        at org.junit.rules.RunRules.evaluate(RunRules.java:20) 
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) 
        at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) 
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) 
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) 
    Caused by: org.openqa.selenium.NoSuchWindowException: Window not found. The browser window may have been closed. 
    Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46' 
    System info: host: 'dev1b', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-4-amd64', java.version: '1.8.0_92' 
    Driver info: driver.version: unknown 
        at <anonymous class>.nsCommandProcessor.prototype.execute(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/command-processor.js:12719) 
        at <anonymous class>.Dispatcher.executeAs/<(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/driver-component.js:9558) 
        at <anonymous class>.Resource.prototype.handle(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/driver-component.js:9705) 
        at <anonymous class>.Dispatcher.prototype.dispatch(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/driver-component.js:9652) 
        at <anonymous class>.WebDriverServer/<.handle(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/driver-component.js:12517) 
        at <anonymous class>.createHandlerFunc/<(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/httpd.js:2054) 
        at <anonymous class>.ServerHandler.prototype.handleResponse(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/httpd.js:2387) 
        at <anonymous class>.Connection.prototype.process(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/httpd.js:1223) 
        at <anonymous class>.RequestReader.prototype._handleResponse(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/httpd.js:1677) 
        at <anonymous class>.RequestReader.prototype._processBody(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/httpd.js:1525) 
        at <anonymous class>.RequestReader.prototype.onInputStreamReady(file:///tmp/anonymous1889291378920456774webdriver-profile/extensions/[email protected]/components/httpd.js:1393) 
    

    問題は、私ということです

(私の実際の問題である)私はWindowNotFoundExceptionを発生させ、このコードを使用していますウィンドウを閉じたいポップアップウィンドウと親ウィンドウの間にはいくつかのデータが共有されており、ポップアップで正しい値を選択すると、このウィンドウは閉じるはずです。

私はすでに例外をキャッチしようとしました。しかし、私はGebに正しいウィンドウ(まだ開いている親ウィンドウ)を使用するように指示する必要があります。

アイデア?

+0

私はまだ解決策を探しています...誰もがアイデアを持っている:あなたはclose option使用して、そうしないことを求めることができますか? – H3ADLESS

答えて

0

だから私は、あなたがアラートで[OK]をクリックすると、あなたはエラーが表示されます。

はゲブはそれが何ページかを知らないような音と、あなたはのwaitForとあなたのコードをラップする必要があります。デフォルトでは

waitFor { 
     withWindow({ isAt MyPage}) { true } 
    } 
+0

ちょっとラッシュビー。お返事をありがとうございます。私はそれがポイントだと思う:Gebはそれがどんなページにあるのか知らない。 コードのどの部分を折り返すべきか明確にすることはできますか?親ウィンドウまたはポップアップウィンドウを確認していますか?私は全体をNewWindowで包んだりしようとしましたが、何か他のものを意味すると思われます。 – H3ADLESS

1

はゲブは、実行の終わりにwithNewWindow()呼び出しによって開かれたウィンドウを閉じますその方法の

withNewWindow({ selectLink.click() }, close: false) { 
    ... 
} 
+0

ちょっとエルディ。お返事をありがとうございます。私はすでにそれを試みましたが、私はまだwithAlertラインで同じエラーを受けています。 – H3ADLESS

関連する問題