Skip to content
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.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeceptjs version > 3.5.8 - Throws DataCloneError when I.executeScript command is used with run-workers (multiple browser parallel execution) #4165

Closed
myrepojuly opened this issue Jan 31, 2024 · 4 comments · Fixed by #4483

Comments

@myrepojuly
Copy link

myrepojuly commented Jan 31, 2024

What are you trying to achieve?

In my application, there are several ReactJS fields for which we utilize the executeScript command to assign values. While this process functions correctly in a non-parallel execution environment, it encounters issues when executed in parallel.

**Note: this works fine with codeceptjs versions lesser than 3.5.8 (Example, with 3.5.6 this error does not occur).
Command to run the test
npx codeceptjs run-workers 2 profile1 --verbose
**

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

Error processing test.after event:
DataCloneError: function (name, func, attachToElement = false, proto, instances) {
            const customCommand = typeof com...<omitted>... } could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at sendToParentThread (E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\command\workers\runTests.js:282:14)
    at EventEmitter.<anonymous> (E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\command\workers\runTests.js:227:49)
    at EventEmitter.emit (node:events:530:35)
    at EventEmitter.emit (node:domain:488:12)
    at Object.emit (E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\event.js:149:28)
    at E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\scenario.js:182:11
    at injectHook (E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\scenario.js:10:5)
    at module.exports.teardown (E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\scenario.js:180:10)
    at Context.<anonymous> (E:\Codeceptjs_pipeline\parenttrigger\node_modules\codeceptjs\lib\ui.js:114:66)

Provide test source code if related

Feature('CodeceptJS test');

const{I} = inject();

Scenario('test something', async () => {
  await I.amOnPage('/react/demos/?_gl=1*1lz342q*_ga*MTY3MTc2MDgxLjE3MDY2ODgzOTg.*_ga_41J4HFMX1J*MTcwNjY4ODM5Ny4xLjAuMTcwNjY4ODM5Ny4wLjAuMA..#/bootstrap5/textboxes/default');
  await I.wait(10); // temp adding a wait
  // for versions < 3.5.8 use helper to locate the element
  const element = await I.grabWebElements({id: 'textbox_2'})
  // set the value in react text field
  await I.executeScript((element, value) => {
    const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
    const prototype = Object.getPrototypeOf(element);
    const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
    if (valueSetter && valueSetter !== prototypeValueSetter) {
        prototypeValueSetter.call(element, value);
    } else {
        valueSetter.call(element, value);
    }
    element.dispatchEvent(new Event('input', { bubbles: true }));
  }, element[0], 'test');
})


Details

  • CodeceptJS version: v3.5.12
  • NodeJS Version: 20.11.0
  • Operating System: Windows 11 10.0.22631 and MacOS
  • puppeteer || webdriverio || testcafe version (if related) : "webdriverio": "^8.29.1"
  • Configuration file:
const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins 
setCommonPlugins();

/** @type {CodeceptJS.MainConfig} */
exports.config = {
   tests: './test.js',
  output: './output',
  helpers: {
    WebDriver: {
      host: 'localhost',
      port: 4444,
      url: 'https://ej2.syncfusion.com/',
      browser: 'MicrosoftEdge',
      windowSize: 'maximize',
      restart: true, 
    }
  },
  multiple: {
    profile1: {
      browsers: [
        {
          browser: "MicrosoftEdge",
        },
        {
          browser: "chrome",
        }
      ]
    }
  },
  include: {
    I: './steps_file.js'
  },
  fullPromiseBased: true,
  name: 'parenttrigger'
}
@myrepojuly
Copy link
Author

@kobenguyent @DavertMik could you pls help with this issue?

@myrepojuly
Copy link
Author

Hello @kobenguyent .. Would you be able to help with this issue?

Copy link

github-actions bot commented May 4, 2024

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale label May 4, 2024
@anils92
Copy link
Contributor

anils92 commented Aug 22, 2024

any update on the issue, we are also facing the same problem.

@github-actions github-actions bot removed the stale label Aug 23, 2024
code4muktesh pushed a commit to code4muktesh/CodeceptJS that referenced this issue Sep 4, 2024
kobenguyent pushed a commit that referenced this issue Sep 4, 2024
#4165

Co-authored-by: muktesh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants