DevExpress / testcafe

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

TestCafe fails with 500 "Failed to load resource" error when trying to load JS file #7461

Closed Artem-Babich closed 1 year ago

Artem-Babich commented 1 year ago

What is the Current behavior?

I have the same problem as mentioned here with testcafe in version 1.19.0, did the upgrade to the latest version 2.2.0 and the problem continues. The .js that can´t be loaded is this: <script src="https://test.frontier7.com/chunk/chunk-BZA67JWP.js"></script>

Put the script in a new React project and Testcafe also gave the same error.

image

What is the Expected behavior? The URL put in .page() should redirect to Login but instead I see the behavior describer here. Also tried to do Login first and then navigate to the project and the behavior is the same.

What is your web application and your TestCafe test code?

import { Selector } from "testcafe";
fixture('CreateProject')
  .page('https://test.frontier7.com/project/63adf96c785a40eb5d88a835/build')

test('log-in and do stuff', async t => {
  await t.wait(2000); 
  const email_input = Selector('input[type="text"]');
  const password_input = Selector('input[type="password"]');
  const submit = Selector('button[type=submit]');
  const email = "email_password";
  const password = "user_password";

  await t.typeText(email_input, email, { replace: true })
  .typeText(password_input, password, { replace: true })
  .click(submit);
});

Steps to Reproduce: To reproduce the bug just load the page with Testcafe

import { Selector } from "testcafe";
fixture('CreateProject')
  .page('https://test.frontier7.com/project/63adf96c785a40eb5d88a835/build')

test('log-in and do stuff', async t => {
  await t.wait(10000000); 
});

Environment details: testcafe version: >2.2.0 node.js version: v18.13.0 command-line arguments: testcafe chrome -e test.js browser name and version: Chrome 108 platform and version: Windows

Originally posted by @Chramox in https://github.com/DevExpress/testcafe/issues/6458#issuecomment-1381994433

For team:

http-playground-sample.zip Error on loading resource directly through http-playground: TypeError: ExprGen[itemType] is not a function

Artem-Babich commented 1 year ago

Hi @Chramox,

I was able to reproduce this issue in the latest version (v2.2.0). TestCafe runs tests using the URL-rewritten proxy. This approach is good, but in this particular case, this proxy was unable to correctly process your resource file. We need additional time to determine the exact cause of this issue.

However, we have a test execution mode that uses native browser automation - we call it the Proxyless mode. In Proxyless mode, a few issues are already fixed. By the way, this issue was also fixed in Proxyless mode.

Try running your tests in Proxyless mode and let us know the results. This option is available in all interfaces:

// Command-line
testcafe chrome tests --experimental-proxyless

// Programmatic
const testcafe = await createTestCafe({​​​​​​​​​ experimentalProxyless: true }​​​​​​​​​);

// Configuration file
{​​​​​​​​​
   "experimentalProxyless": "true"
}​​​​​​​​​    

Note that this is an experimental feature so far.

Also, the Proxyless mode is implemented only in Google Chrome. It will not work correctly if you run tests in a non-Chrome browser.

Chramox commented 1 year ago

Thank you @Artem-Babich for the help. I was ran my tests with the Proxyless mode. But I found other problem that the login never saved the session. So, when I was trying to load the page when de 500 error is, I was returned to the login again.

Artem-Babich commented 1 year ago

Hi @Chramox

Thank you for the clarification. Our new proxyless mode is still experimental, but we are actively working on it to improve user experience. Would you please clarify if you are using roles to perform your authorization? If not, try using a role and run the test with the experimental proxyless flag enabled. If the issue still occurs, please send us a simple working project so that we can reproduce it locally.

Chramox commented 1 year ago

With TestCafe v2.3.0 with proxylesss mode is working properly. Original problem still there without proxyless mode.

testcafe-HK commented 1 year ago

Hi, I am having the same kind of issue My login button is frozen when I am opening via testcafe . I see an error in browser console log "Failed to load resource: the server responded with a status of 404 (Not Found)"

But , When I open the url manually , I am able to login and I don't have any error. I have testcafe 2.3.0 version in my Gherkin-testcafe .

await t .typeText('#username', username) .typeText('password', 'xxxxxxxx') ; await t .setNativeDialogHandler(() => true) .click('#submit'); I am using this command to run the test gherkin-testcafe chrome tests/Adjuster.js features/Adjuster.feature --experimental-proxyless

Jgrabenbauer commented 1 year ago

We are getting this all of a sudden as well with no changes to the Testcafe or Node version. We tried updating to Testcafe v2.5.0 & ran scripts with the --native-automation flag but there is still the same failure just after the first step in the script runs.

aleks-pro commented 1 year ago

Hello @testcafe-HK , @Jgrabenbauer ,

Since the original issue is not reproduced with the Native Automation (Proxyless) mode enabled, that means the behavior you encountered has a different cause. Please create a separate issue with a working example with which we can reproduce the incorrect behavior.

aleks-pro commented 1 year ago

Hello @Chramox ,

We will close this issue since it is fixed in Native Automation mode. Feel free to reopen the issue if you cannot use Native Automation for some reason.

davidcsmtui commented 1 year ago

Hello, running our pipelines we suddenly have this error

Error details:
      TypeError: ExprGen[itemType] is not a function
      Browser: Chrome 109.0.5414.119 / Linux 0.0

Our configuration is TestCafe 2.2.0 and we tried using the --experimental-proxyless parameter but still happening. Any help, please?

tgrisley commented 1 year ago

Hello, we are also suddenly seeing the same error as @davidcsmtui in our pipelines.

Error details: TypeError: ExprGen[itemType] is not a function Browser: Chrome 112.0.0.0 / macOS 10.15.7

Using --experimental-proxyless does not seem to help.

Currently running TestCafe 2.4.0

patrickathompson commented 1 year ago

Hello @Chramox ,

We will close this issue since it is fixed in Native Automation mode. Feel free to reopen the issue if you cannot use Native Automation for some reason.

Native Automation is not supported by Browserstack, so cannot use it. I am also seeing this error crop up randomly out of nowhere.

ayemelyanenko-chegg commented 1 year ago

@aleks-pro Hello, I am also seeing it happen suddenly today, same as the people above. Switching to native automation is not an option as it's still not fully functional for my company's use case due to this outstanding issue https://github.com/DevExpress/testcafe/issues/7588

I am on TestCafe 2.5, this is the sample test

fixture `My First fixture`
    .page `https://www.easybib.com/`;

test('My first test', async t=> {
   console.log("Hello");
});

This is the error

Failed to load the page at "https://www.easybib.com/".
  Increase the value of the "pageRequestTimeout" variable, enable the "retryTestPages" option, or use quarantine mode to perform additional attempts to execute this test.
  You can find troubleshooting information for this issue at "https://go.devexpress.com/TestCafe_FAQ_ARequestHasFailed.aspx".

  Error details:
  TypeError: ExprGen[itemType] is not a function

  Browser: Chrome 112.0.0.0 / macOS 10.15.7

Please reopen this issue as not everyone can use native automation.

claudiacol commented 1 year ago

Hello, I am also suddenly seeing the same error as @davidcsmtui in my pipelines.

Error details: TypeError: ExprGen[itemType] is not a function

Browser: Chrome 112.0.0.0 / Catalina 10.15

Using --native-automation option does not solve the problem. I'm using Testcafe v2.5.0

Can you please address this problem? Native automation is not solving our issue.

Currently running TestCafe 2.5.0

mistyhickman commented 1 year ago

Is there another thread for this issue? I am also seeing the same error as of about 3-4 days ago.

Error details: TypeError: ExprGen[itemType] is not a function Logging also shows "Unhandled Exception: Failed to load the page at "URL". No code changes, no updated, no server changes, etc. It was working last week every day it ran until Thursday when it failed and has continued to do so since then.

TestCafe version 2.4.0

davidcsmtui commented 1 year ago

I just realised there was a release of testcafe-hammerhead last Thursday. Could it be related? Thanks in advance

Screenshot 2023-04-17 at 17 55 07
patrickathompson commented 1 year ago

applying yarn or npm patch works: https://github.com/DevExpress/testcafe/issues/7632#issuecomment-1510974419

ayemelyanenko-chegg commented 1 year ago

@mistyhickman There is an open issue here https://github.com/DevExpress/testcafe/issues/7632

aleks-pro commented 1 year ago

Hello guys,

Please continue the discussion regarding the error here: https://github.com/DevExpress/testcafe/issues/7632.