testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Uncaught object "[object Object]" was thrown. Throw Error instead with every single action after switchToIframe with TestCafe versions >1.15.2

Open anderconal opened this issue 3 years ago • 17 comments

What is your Scenario?

  • We have some working tests with TestCafe version 1.15.2
  • We'd like to be able to update TestCafe version frequently without broken existing tests

What is the Current behavior?

  • If we update TestCafe to any version bigger than 1.15.2 (we tested with 1.15.3-rc.1, 1.15.3, 1.17.0, 1.18.0...) then some of the previously existing and working tests starts to fail
  • The failure occurs after make use of switchToIframe and try to perform any action (or assert something)
  • The error is always the same for Chrome
    • Uncaught object "[object Object]" was thrown. Throw Error instead.
  • For Firefox, the test never ends, no error is shown and the Firefox instance remains open forever
  • The error occurs only on some iframes, others remains working as expected
  • No code change have been made on tests, only TestCafe version update

What is the Expected behavior?

  • If we update TestCafe to any version bigger than 1.15.2 then all the previously existing and working tests remains working as before

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

What is your TestCafe test code?

import { Role, Selector } from "testcafe";
import { screen } from '@testing-library/testcafe';

const adminUserRole = Role(`https://id.whatever.com/login`, async t =>{
    await t.typeText(Selector('#username'), 'me@emailcom');
    await t.click(screen.getByText('Continue'))
    await t.typeText(Selector('#password'), '')
    await t.click(screen.getByText('Log in'));
})

fixture `example-1`
    .page`https://whatever.net/your-page`

test('Add read confirmation', async function(t){
    await t.setTestSpeed(0.5);
    await t.maximizeWindow();

    await t.useRole(adminUserRole);
    const dotdotdotSelector = Selector(screen.getByTestId('content-tools-dropdown-menu--trigger'));
    await t.click(dotdotdotSelector);

    const addReadConfSelector =  Selector(screen.getByText(/add read confirmation/i));
    await t.click(addReadConfSelector);

    const addIframeSelector = '[id^=\'my_iframe_id__\']';
    await t.expect(Selector(addIframeSelector).exists).ok();
    console.log('addIframeSelector exists before switch to iframe');
    await t.switchToIframe(Selector(addIframeSelector));
    console.log('switched to addIframeSelector');
    const confirmButton = Selector(screen.getByRole('button', { name: /confirm/i }));
    console.log('This is the last point that works. Every single interaction on the iframe will fail for TestCafe versions > 1.15.2 with Uncaught object "[object Object]" was thrown. Throw Error instead.');
    await t.click(confirmButton); // This fails with Uncaught object "[object Object]" was thrown. Throw Error instead.
    console.log('You can not arrive here. No action is working');
});

Your complete configuration file

{
  "clientScripts": [{ "module": "@testing-library/dom/dist/@testing-library/dom.umd.js" }],
  "screenshotPath": "./screenshots",
  "screenshotPathPattern": "${DATE}_${TIME}/${FIXTURE}.png",
  "skipJsErrors": true,
  "concurrency": 1,
  "takeOnFails": true,
  "disablePageCaching": true,
  "disableScreenshots": true
}

Your complete test report

Running tests in:

  • Chrome 96.0.4664.110 / macOS 10.15.7

example-1 addIframeSelector exists before switch to iframe switched to addIframeSelector This is the last point that works. Every single interaction on the iframe will fail for TestCafe versions > 1.15.2 with Uncaught object "[object Object]" was thrown. Throw Error instead. ✖ Add read confirmation

  1. Uncaught object "[object Object]" was thrown. Throw Error instead.

    Browser: Chrome 96.0.4664.110 / macOS 10.15.7

1/1 failed (43s)

Screenshots

No response

Steps to Reproduce

  1. Clone the minimal working example from GitHub
  2. Follow the README.md instructions
  3. See the test fail

TestCafe version

1.15.3, 1.17.0, 1.18.0

Node.js version

12.12.0

Command-line arguments

node ./node_modules/testcafe/bin/testcafe.js chrome example-1.test.js

Browser name(s) and version(s)

Chrome 96.0.4664.110, Firefox 95.0

Platform(s) and version(s)

macOS 10.15.7

Other

No response

anderconal avatar Jan 04 '22 11:01 anderconal

Hi,

We need access to your project's GitHub repository to reproduce the issue, please send it to [email protected].

AlexanderMoiseev avatar Jan 06 '22 15:01 AlexanderMoiseev

Hi @anderconal

Could you please give access to the repository with the example to @miherlosev?

miherlosev avatar Jan 07 '22 10:01 miherlosev

Hello!

First of all, thanks for your quick response.

You should have received an invitation:

See image: https://user-images.githubusercontent.com/19661411/148911720-bc5a9bff-7f98-4b10-826c-07dfd1bbb1be.png

Best,

Ander Conal

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, January 6th, 2022 at 4:47 PM, AlexanderMoiseev @.***> wrote:

Hi,

We need access to your project's GitHub repository to reproduce the issue, please send it to @.***

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

anderconal avatar Jan 10 '22 07:01 anderconal

You should have received an invitation: [image.png]

I didn't see any notification. Please try adding access to the example's repository using steps from the following help article.

miherlosev avatar Jan 11 '22 08:01 miherlosev

Already sent the invitation. See:

image

And now to your user too:

image

Best,

Ander Conal

anderconal avatar Jan 11 '22 08:01 anderconal

I run the shared example with the latest TestCafe version (v1.18.2-alpha.1), and all works fine. image

Try to run your tests with this version and let us know about the results.

miherlosev avatar Jan 12 '22 08:01 miherlosev

Hello,

I'm trying to test it with v1.18.2-alpha.1 and the following message is appearing all the time:

TestCafe requires permission to record the screen. Open 'System Preferences > Security & Privacy > Privacy > Screen Recording' and check 'TestCafe Browser Tools' in the application list.

I already followed:

  • https://github.com/DevExpress/testcafe/issues/4684

And tried to:

  • Uncheck, lock, check, lock
  • Press the minus button, lock, Press any key to retry, check, lock
  • Both options with a computer restart after each change

image

It is not working and I can not continue with the test.

Should I try to do something more?

anderconal avatar Jan 13 '22 09:01 anderconal

Hello @anderconal ,

Please follow this guide to obtain the necessary permissions: https://testcafe.io/403664/release-notes/framework/2021-12-22-testcafe-v1-18-0-released#testcafe-browser-tools-macos-permission-fix

Let us know if this helps.

aleks-pro avatar Jan 14 '22 08:01 aleks-pro

Thanks @aleks-pro I'll check it this morning and update you. Thanks a lot!

anderconal avatar Jan 14 '22 08:01 anderconal

Hey @aleks-pro the guide you provided worked nicely!

BTW @miherlosev I still see the same error after update to 1.18.2-alpha.1:

image

Am I missing something? Should I test it other way?

anderconal avatar Jan 14 '22 09:01 anderconal

Hi @anderconal,

After several attempts, I was able to reproduce the issue using the example you shared. Thank you for the detailed information and your cooperation.

miherlosev avatar Jan 17 '22 08:01 miherlosev

Thanks @miherlosev for you time, patience and quick responses.

If you need anything from our part, please, just ask!

anderconal avatar Jan 17 '22 08:01 anderconal

Hi @miherlosev from now on I'll be the responsible of this issue so do not hesite to contact me for further required info of whatever you need. I hope to know soon about a fix of this issue. Thanks

ipy76 avatar Feb 01 '22 16:02 ipy76

Hello, I encountered a repetitive mod of this error: I ran the automated test suite with concurrency 3 and it thrown the [object][object] error. When the suite is ran regularly, there is no error displayed. Any ideas of the status of this issue? Thank you, Marius

mariusstaicu22 avatar Apr 04 '22 09:04 mariusstaicu22

Any personal estimate may be misleading, so we cannot currently tell it at the moment. Once we get any results, we will post them in this thread.

testcafe-build-bot avatar Apr 05 '22 11:04 testcafe-build-bot

Hey! I got this error too now. I tried to work around https://github.com/DevExpress/testcafe/issues/7206 by adding an expect and I get this error now. o.o

liviuavram avatar Jul 28 '22 15:07 liviuavram

We do not have any updates on the status of the issue. Once we have any results, we'll post them here.

AlexKamaev avatar Jul 29 '22 07:07 AlexKamaev

Hello,

We released a new TestCafe version (v2.3.0), which includes experimental proxyless mode. This mode uses native browser automation. In Proxyless mode, a few issues are already fixed. This issue should also be fixed in Proxyless mode.

Unfortunately, I was not able to test your web site since the URL you shared is no longer available. Would you please check if your sample is working correctly in v2.3.0 with experimental proxyless mode enabled? 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"
}    

Please keep in mind that this mode is still experimental and is implemented only in Google Chrome. It will not work correctly if you run tests in a non-Chrome browser or in a combination of other browsers.

Artem-Babich avatar Feb 01 '23 07:02 Artem-Babich

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

github-actions[bot] avatar Feb 11 '23 08:02 github-actions[bot]