DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 672 forks source link

TestCafe is disconnecting from the browser upon login - [ERROR]: browser disconnected. If you did not close the browser yourself, browser performance or network issues may be at fault. #6942

Closed yoavws closed 2 years ago

yoavws commented 2 years ago

What is your Scenario?

Login to Heroku , reach main page.

The behaviour of the browser with TestCafe differ from regular usage (Tested with multiple browsers and TC versions)

After we will try to login the connection of TC and the browser is lost. TC will try to execute 2 more times till we will fail.

What is the Current behavior?

Fail to login and loopback to login page while testcafe loses the connection to the browser

What is the Expected behavior?

Login will pass and we will reach main Heroku page

What is your public website URL? (or attach your complete example)

https://id.heroku.com/login

What is your TestCafe test code?

import { Selector, ClientFunction } from 'testcafe';

const textinputEmailAddress = Selector('[name=\'email\']');
const textinputPassword = Selector('[name=\'password\']');
const buttonSubmit =  Selector('[type=submit]');
const headingPrimary = Selector('h2').withText('Log in to your account');

fixture `Heroku login failure fixture`
    .page('https://id.heroku.com/login');
test('Login to heroku', async t => {
    await t.expect(headingPrimary.exists).ok('The \'Login\' page title', { timeout: 10000 });
    await t
        .typeText(textinputEmailAddress, ANY-USER, { replace: true, paste: true })
        .typeText(textinputPassword, 'ANY-USER-PASS', { replace: true, paste: true })
        .click(buttonSubmit);
    console.log('click on later button');
    const buttonLater = Selector('button').withText('Later');
    await t.click(buttonLater);
    console.log('verify we looped back to login, instead of reaching https://dashboard.heroku.com/apps');
    await t.expect(headingPrimary.exists).ok('The \'Login\' page title', { timeout: 10000 });
});

Your complete configuration file

no config required in this example: testcafe chrome ./automation/tests/testcafe_disconnect_reproduction.ts

Your complete test report

Heroku login failure fixture "click on later button verify we looped back to login, instead of reaching https://dashboard.heroku.com/apps "click on later button verify we looped back to login, instead of reaching https://dashboard.heroku.com/apps "click on later button verify we looped back to login, instead of reaching https://dashboard.heroku.com/apps ERROR The Chrome 99.0.4844.83 / macOS 10.15.7 browser disconnected. If you did not close the browser yourself, browser performance or network issues may be at fault.

Screenshots

No response

Steps to Reproduce

1.Create a free Heoku user 2.Update credentials in the shorten example I supplied 3.Execute the code example with testcafe chrome ./RELATIVE_PATH/FILE_NAME.ts

TestCafe version

1.18.1 (reproduced with 1.14.1 as well)

Node.js version

12/14/16

Command-line arguments

testcafe chrome ./RELATIVE_PATH/FILE_NAME.ts

Browser name(s) and version(s)

Chrome/FF/Safari

Platform(s) and version(s)

Mac/ubuntu

Other

Adding more debugging info upon failure will be great, why we lost the connection, what can be done to avoid etc.

AlexKamaev commented 2 years ago

Thank you for pointing out the issue to us. I managed to reproduce this issue.

yoavws commented 2 years ago

Thank you for pointing out the issue to us. I managed to reproduce this issue.

Thanks Alex, I tried to bring more details from the transport layer, I remembered I found a flag for hammer-head in the past to generate traffic dump, but wasn't able to found it in the documentation.😖

Didn't found the ability to print transport dump from testcafe but followed the instrunctions here

And got these errors:

DevTools failed to load source map: Could not parse content for https://dashboard.heroku.com/auth/heroku/plugin.css.map: Unexpected token < in JSON at position 0
DevTools failed to load source map: Could not load content for http://localhost:1401/wAJ4v923F!f/https:/id.heroku.com/plugin.css.map: Load canceled due to load timeout
DevTools failed to load source map: Could not load content for http://localhost:1401/wAJ4v923F!s!utf-8/https:/dashboard.heroku.com/assets/dashboard-bcac314accc23f4eb74dfa85598828e1.map: Load canceled due to load timeout

and Error in hammerhead:

(node:77276) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_URL]: Invalid URL: https://
    at new NodeError (internal/errors.js:322:7)
    at onParseError (internal/url.js:270:9)
    at new URL (internal/url.js:346:5)
    at Object.connect (internal/http2/core.js:3184:17)
    at /Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/destination-request/http2.js:37:41
    at new Promise (<anonymous>)
    at Object.getHttp2Session (/Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/destination-request/http2.js:36:28)
    at DestinationRequest._send (/Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/destination-request/index.js:108:27)
    at new DestinationRequest (/Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/destination-request/index.js:42:14)
    at /Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/utils.js:37:88
    at new Promise (<anonymous>)
    at Object.sendRequest (/Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/utils.js:36:12)
    at Array.sendDestinationRequest (/Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/stages.js:59:27)
    at Object.run (/Users/yoav/vscode-projects/testcafe-hammerhead/lib/request-pipeline/index.js:19:34)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:77276) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:77276) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
AlexKamaev commented 2 years ago

I suppose you mean the verbose debugging log. If so, you can set the environment variables as mentioned in the following StackOverflow thread: https://stackoverflow.com/questions/68225130/testcafe-failing-to-connect-to-server-when-using-proxy-option.

As for the hammerhead error and warning, we'll check them when we start researching the issue.

yoavws commented 2 years ago

We found an even shorter reproduction, just navigating to https://dashboard.heroku.com/apps will crash hammerhead. (the browser will follow the redirect back to the login page)

fixture `Heroku login failure fixture`
    .page('https://dashboard.heroku.com/apps');

Login isn't required, seems the redirect operation do not sit well with the proxy Trace logs: hammerhead-log.txt

Also using --disable-http2 didn't help.

yoavws commented 2 years ago

In another inspection into the exception. It seems the site(Heroku) or some where in hammerhead we get: 2022-03-31T16:26:18.488Z hammerhead:proxy Proxy request peGyY7Sa9 GET /Xrhq9HRjC!s!utf-8/https:/dashboard.heroku.com/assets/dashboard-7637d7a128b471b8fbdef430fedda9dd.map

the proxy crash is seems to be crashing due to the protocol scheme typo: we get https:/ instead of https://

from testcafe execution we get the same:

mendybr commented 2 years ago

Same issue here, we try to debug but without success.

Aleksey28 commented 2 years ago

Thank you for your feedback. We don't have any updates yet. We will update this thread once we have news.

vlads11 commented 2 years ago

Are there any updates worth sharing on this issue?

github-actions[bot] commented 2 years ago

No updates yet. Once we get any results, we will post them in this thread.

yoavws commented 2 years ago

Are there any updates worth sharing on this issue?

@vlads11 maybe share what you seeing, it might help, we started to debug into hammer-head, but as there is not enough of debug information, came to a halt without knowing the project internals

yoavws commented 2 years ago

Thank you for your feedback. We don't have any updates yet. We will update this thread once we have news.

@Aleksey28 we seen today 1.18.6 is not reproducing the issue (reproduced with all versions we tried from 1.14-1.18.5) In 1.18.6 there is a proxy upgrade, did this issue got partial fix?

vlads11 commented 2 years ago

@yoavws after further investigation I believe the error we're seeing is different than this. Running into issues with hammerhead 302 redirect page loads after authentication. The tests just hang and the page never completes loading. Looking to open a separate issue for my problem but having a hard time describing it and making it actionable.

Artem-Babich commented 2 years ago

@yoavws, I confirm that this issue is not reproduced in v1.18.6. We made significant code changes between these versions.

@vlads11, I'm afraid we cannot give you any recommendations. To determine the cause of the issue, we need to reproduce and research it. So, feel free to create a new GitHub issue and share a minimal working example illustrating the problem: How To: Create a Minimal Working Example When You Submit an Issue.

You can use the following template to create the GitHub issue: Issue Template.

We are closing this issue since it is not reproducible in v1.18.6.