在新 window 中关闭确认对话框后 Geb 未指向正确的页面
Geb not pointing to right page after closing confirm dialog in new window
我在 groovy 中使用 geb 进行测试自动化,目前处理的场景如下:
首先,我在父 window 中,从那里我打开新的 window 并在那里进行一些搜索,单击搜索结果会生成确认对话框并更新父页面中的值,使用 withConfirm 绕过对话框().然后我来到 parent window 但之后没有任何执行。我认为 geb 在页面之间变得混乱。
In parent Page
open new window
search for something
click on the first search result
clicking on it opens a confirm dialog
click okay and close the new window
continue with parent window
我的代码如下:
withNewWindow(close: false,wait:true,{$(button that opens new window).click()}) {
waitFor{
title == "title"
}
withConfirm(wait: true){$(cause to open confirm dialog).click()}
}
$("input[name='button'][id='SAVE_FOOTER']").click()
}
错误:
Caught: org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'DESKTOP-NAFK3F3', ip: '10.1.10.195', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 12824, moz:profile: C:\Users\Dell\AppData\Local..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 2c0c768c-785f-49d4-bdff-186566e722dd
org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'DESKTOP-NAFK3F3', ip: '10.1.10.195', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 12824, moz:profile: C:\Users\Dell\AppData\Local..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 2c0c768c-785f-49d4-bdff-186566e722dd
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at geb.js.JavascriptInterface.execjs(JavascriptInterface.groovy:66)
at geb.js.JavascriptInterface.exec(JavascriptInterface.groovy:56)
at geb.js.DefaultAlertAndConfirmSupport.popLastDialogFunctionOnto(DefaultAlertAndConfirmSupport.groovy:114)
at geb.js.DefaultAlertAndConfirmSupport.captureDialog(DefaultAlertAndConfirmSupport.groovy:168)
at geb.js.DefaultAlertAndConfirmSupport.captureConfirm(DefaultAlertAndConfirmSupport.groovy:182)
at geb.js.DefaultAlertAndConfirmSupport.withConfirm(DefaultAlertAndConfirmSupport.groovy:54)
at geb.js.DefaultAlertAndConfirmSupport.withConfirm(DefaultAlertAndConfirmSupport.groovy)
at geb.js.AlertAndConfirmSupport$withConfirm.call(Unknown Source)
at geb.Page.withConfirm(Page.groovy:130)
at geb.Browser.methodMissing(Browser.groovy:249)
at geb.Browser.invokeMethod(Browser.groovy)
at CRMPageExample$_run_closure1$_closure3.doCall(CRMPageExample.groovy:149)
at CRMPageExample$_run_closure1$_closure3.doCall(CRMPageExample.groovy)
at geb.Browser.withNewWindow(Browser.groovy:798)
at CRMPageExample$_run_closure1.doCall(CRMPageExample.groovy:137)
at CRMPageExample$_run_closure1.doCall(CRMPageExample.groovy)
at geb.Browser.drive(Browser.groovy:128)
at geb.Browser$drive[=13=].callStatic(Unknown Source)
at geb.Browser.drive(Browser.groovy:98)
at geb.Browser$drive.call(Unknown Source)
at CRMPageExample.run(CRMPageExample.groovy:97)
1552494416789 Marionette INFO Stopped listening on port 52107
[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 2628, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 2628, Chrome_ChildThread] WARNING: pipe error: 109: file [Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 8068, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 8068, Chrome_ChildThre
###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv
我试过的方法好像没用
waitFor{
withwindow{Parent window}){true}
}
这看起来像是切换时 Geb 警报处理中的一个潜在问题 windows。请帮我一个忙 post 这是 the tracker 中的一个问题,包括您提供的代码和堆栈跟踪?等我几周后放假回来再看看。
我在 groovy 中使用 geb 进行测试自动化,目前处理的场景如下: 首先,我在父 window 中,从那里我打开新的 window 并在那里进行一些搜索,单击搜索结果会生成确认对话框并更新父页面中的值,使用 withConfirm 绕过对话框().然后我来到 parent window 但之后没有任何执行。我认为 geb 在页面之间变得混乱。
In parent Page
open new window
search for something
click on the first search result
clicking on it opens a confirm dialog
click okay and close the new window
continue with parent window
我的代码如下:
withNewWindow(close: false,wait:true,{$(button that opens new window).click()}) {
waitFor{
title == "title"
}
withConfirm(wait: true){$(cause to open confirm dialog).click()}
}
$("input[name='button'][id='SAVE_FOOTER']").click()
}
错误:
Caught: org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'DESKTOP-NAFK3F3', ip: '10.1.10.195', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 12824, moz:profile: C:\Users\Dell\AppData\Local..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 2c0c768c-785f-49d4-bdff-186566e722dd
org.openqa.selenium.NoSuchWindowException: Browsing context has been discarded
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'DESKTOP-NAFK3F3', ip: '10.1.10.195', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 65.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 12824, moz:profile: C:\Users\Dell\AppData\Local..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 2c0c768c-785f-49d4-bdff-186566e722dd
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at geb.js.JavascriptInterface.execjs(JavascriptInterface.groovy:66)
at geb.js.JavascriptInterface.exec(JavascriptInterface.groovy:56)
at geb.js.DefaultAlertAndConfirmSupport.popLastDialogFunctionOnto(DefaultAlertAndConfirmSupport.groovy:114)
at geb.js.DefaultAlertAndConfirmSupport.captureDialog(DefaultAlertAndConfirmSupport.groovy:168)
at geb.js.DefaultAlertAndConfirmSupport.captureConfirm(DefaultAlertAndConfirmSupport.groovy:182)
at geb.js.DefaultAlertAndConfirmSupport.withConfirm(DefaultAlertAndConfirmSupport.groovy:54)
at geb.js.DefaultAlertAndConfirmSupport.withConfirm(DefaultAlertAndConfirmSupport.groovy)
at geb.js.AlertAndConfirmSupport$withConfirm.call(Unknown Source)
at geb.Page.withConfirm(Page.groovy:130)
at geb.Browser.methodMissing(Browser.groovy:249)
at geb.Browser.invokeMethod(Browser.groovy)
at CRMPageExample$_run_closure1$_closure3.doCall(CRMPageExample.groovy:149)
at CRMPageExample$_run_closure1$_closure3.doCall(CRMPageExample.groovy)
at geb.Browser.withNewWindow(Browser.groovy:798)
at CRMPageExample$_run_closure1.doCall(CRMPageExample.groovy:137)
at CRMPageExample$_run_closure1.doCall(CRMPageExample.groovy)
at geb.Browser.drive(Browser.groovy:128)
at geb.Browser$drive[=13=].callStatic(Unknown Source)
at geb.Browser.drive(Browser.groovy:98)
at geb.Browser$drive.call(Unknown Source)
at CRMPageExample.run(CRMPageExample.groovy:97)
1552494416789 Marionette INFO Stopped listening on port 52107
[Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 2628, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 2628, Chrome_ChildThread] WARNING: pipe error: 109: file [Parent 12824, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 8068, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 332
[Child 8068, Chrome_ChildThre
###!!! [Child][MessageChannel::SendAndWait] Error: Channel error: cannot send/recv
我试过的方法好像没用
waitFor{
withwindow{Parent window}){true}
}
这看起来像是切换时 Geb 警报处理中的一个潜在问题 windows。请帮我一个忙 post 这是 the tracker 中的一个问题,包括您提供的代码和堆栈跟踪?等我几周后放假回来再看看。