You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot close the window because it does not have a parent. The parent window was closed or you are attempting to close the root browser window where tests were launched.
#5597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
I would like to open a new window with a different application under different url. Sign in there and do some actions then return to the parent window to continue my test.
As an example the code below uses github as a platform to sign in.
What is the Current behavior?
The test fails because the window cannot be closed.
1) Cannot close the window because it does not have a parent. The parent window was closed or
you are attempting to close the root browser window where tests were launched.
What is the Expected behavior?
The test should succeed and close the recently opened window.
What is your web application and your TestCafe test code?
Your complete test code (or attach your test files):
import{Selector,t}from'testcafe';constGITHUB_LOGIN='YOUR GITHUB LOGIN';constGITHUB_PASSWORD='YOUR GITHUB PASSWORD';exportconstresize=()=>t.resizeWindow(1366,700);constgetWindowUrl=()=>t.eval(()=>document.documentURI)asPromise<string>;asyncfunctionopenAsNewWindow(windowUrl: string){constparentUrl=awaitgetWindowUrl();constchildWindow=awaitt.openWindow(windowUrl);constchildUrl=awaitgetWindowUrl();awaitt.expect(childUrl).eql(windowUrl);returnasync()=>{awaitt.closeWindow(childWindow);awaitt.expect(getWindowUrl()).eql(parentUrl);};}fixture('New window').page('https://github.com/join?source=login').beforeEach(resize);test.only('should open a new window',async()=>{awaitt.typeText(Selector('input[type="text"][name="user[login]"]'),'TestCafe');constcloseWindow=awaitopenAsNewWindow('https://github.com/login');awaitt.typeText(Selector('input[type="text"][name="login"]'),GITHUB_LOGIN).typeText(Selector('input[type="password"][name="password"]'),GITHUB_PASSWORD).click(Selector('input[type="submit"][value="Sign in"]'));awaitcloseWindow();awaitt.click(Selector('input[type="submit"][value="Sign in"]'));});
Your complete test report:
15:32 $ npm run test> e2e@1.0.0 test /Users/john/Desktop/Dev/myApp/e2e
> npm run clean && npm run env && testcafe chrome src -S -s screenshots
> e2e@1.0.0 clean /Users/john/Desktop/Dev/myApp/e2e
> rm -rf ./screenshots && mkdir screenshots
> e2e@1.0.0 env /Users/john/Desktop/Dev/myApp/e2e
> rm -rf ./.env && cp ./.env.dev ./.env
Running tests in:
- Chrome 85.0.4183.121 / macOS 10.14.6
New window
✖ should open a new window
(screenshots:
/Users/john/Desktop/Dev/myApp/e2e/screenshots/2020-10-01_15-32-55/test-1/Chrome_85.0.4183.121_macOS_10.14.6/errors/1.png)
1) Cannot close the window because it does not have a parent. The parent window was closed or
you are attempting to close the root browser window where tests were launched.
Browser: Chrome 85.0.4183.121 / macOS 10.14.6
Screenshot:
/Users/john/Desktop/Dev/myApp/e2e/screenshots/2020-10-01_15-32-55/test-1/Chrome_85.0.4183.121_macOS_10.14.6/errors/1.png
19 | const pageWindowUrl = await getWindowUrl();
20 |
21 | await t.expect(pageWindowUrl).eql(loginUrl);
22 |
23 |returnasync () => {
> 24 | await t.closeWindow(pageWindow);
25 |
26 | const currentMainWindowUrl = await getWindowUrl();
27 | await t.expect(currentMainWindowUrl).eql(mainWindowUrl);
28 | };
29 | }
at PageObject.<anonymous>
(/Users/john/Desktop/Dev/myApp/e2e/src/PageObject.ts:24:15)
at <anonymous>
(/Users/john/Desktop/Dev/myApp/e2e/src/PageObject.ts:7:71)
at __awaiter
(/Users/john/Desktop/Dev/myApp/e2e/src/PageObject.ts:3:12)
at <anonymous>
(/Users/john/Desktop/Dev/myApp/e2e/src/PageObject.ts:23:23)
at Object.<anonymous>
(/Users/john/Desktop/Dev/myApp/e2e/src/myTest.spec.ts:47:9)
at fulfilled
(/Users/john/Desktop/Dev/myApp/e2e/src/myTest.spec.ts:4:58)
1/1 failed (34s)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! e2e@1.0.0 test: `npm run clean && npm run env && testcafe chrome src -S -s screenshots`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the e2e@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/john/.npm/_logs/2020-10-01T13_33_33_023Z-debug.log
Steps to Reproduce:
Use your own login / password to be able to login to github in the test.
The problem doesn't occur if a form is not submitted in the freshly opened window.
Is there anything specific that could break TestCafe window management mechanism?
Hello. Thank you for your input. I was able to reproduce the issue.
I examined our code, and it looks like your assumption is correct. The issue occurs only after the form is submitted in the child window. We'll try to fix the issue in the near future.
What is your Test Scenario?
I would like to open a new window with a different application under different url. Sign in there and do some actions then return to the parent window to continue my test.
As an example the code below uses github as a platform to sign in.
What is the Current behavior?
The test fails because the window cannot be closed.
What is the Expected behavior?
The test should succeed and close the recently opened window.
What is your web application and your TestCafe test code?
Your complete test code (or attach your test files):
Your complete test report:
Steps to Reproduce:
The problem doesn't occur if a form is not submitted in the freshly opened window.
Is there anything specific that could break TestCafe window management mechanism?
Your Environment details:
1.9.3
v12.18.3
testcafe chrome src -S -s screenshots
Chrome 85.0.4183.121
macOS 10.14.6
n/a
The text was updated successfully, but these errors were encountered: