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

Issues with tryTo and highlightElement using Playwright #3895

Closed
cjhille opened this issue Sep 27, 2023 · 0 comments · Fixed by #3896
Closed

Issues with tryTo and highlightElement using Playwright #3895

cjhille opened this issue Sep 27, 2023 · 0 comments · Fixed by #3896

Comments

@cjhille
Copy link
Contributor

cjhille commented Sep 27, 2023

Two issues:

  • tryTo() leads to highlightElement being set to true, even though it's disabled
  • highlightElement throws errors under certain conditions

See Slack thread for more details:
https://codeceptjs.slack.com/archives/C94G8JXJB/p1695695685024739
Example.zip: highlight_error_sample.zip

Codeceptjs Version: 3.5.5
Playwright Version: 1.35.1
OS: MacOS x86

Error:

Error: Unexpected value
    at innerSerializeValue ( application/e2e_tests/node_modules/playwright-core/lib/protocol/serializers.js:186:9)
    at innerSerializeValue ( application/e2e_tests/node_modules/playwright-core/lib/protocol/serializers.js:179:10)
    at innerSerializeValue ( application/e2e_tests/node_modules/playwright-core/lib/protocol/serializers.js:179:10)
    at innerSerializeValue ( application/e2e_tests/node_modules/playwright-core/lib/protocol/serializers.js:179:10)
    at innerSerializeValue ( application/e2e_tests/node_modules/playwright-core/lib/protocol/serializers.js:179:10)
    at serializeValue ( application/e2e_tests/node_modules/playwright-core/lib/protocol/serializers.js:97:10)
    at serializeArgument ( application/e2e_tests/node_modules/playwright-core/lib/client/jsHandle.js:101:49)
    at Frame.evaluate ( application/e2e_tests/node_modules/playwright-core/lib/client/frame.js:173:44)
    at Page.evaluate ( application/e2e_tests/node_modules/playwright-core/lib/client/page.js:383:28)
    at module.exports.highlightElement ( application/e2e_tests/node_modules/codeceptjs/lib/helper/scripts/highlightElement.js:11:13)

test.js

Feature('regression');

Scenario('trigger highlight error with tryTo', 
async ({ pageObject }) => {
    await pageObject.useTryTo();
});

pageObject.js

const { I } = inject();

module.exports = {
  
  async useTryTo() {
    I.amOnPage('https://codecept.io/');
    await tryTo(() => {
      // NOTE: in tryTo, debugMode is set to true
      this.fillAField();
    })
  },

  async fillAField() {
    // which causes this to have highlight although it's disabled
    // and highlight() has issues with this context in 3.5.5
    // but used to be okay in 3.5.3
    I.fillField('#algolia-search-input', "foobar")
  },

}

config.js

exports.config = {
  tests: './*_test.js',
  output: '.',
  helpers: {
    Playwright: {
      url: "",
      highlightElement: false,
    },
  },
  plugins: {
    tryTo: { enabled: true },
  },
  include: {
    pageObject: './pageObject.js',
  },
  name: '_codecepterror'
}

and package.json

{
    "name": "codeceptjs-tests",
    "version": "0.1.0",
    "private": true,
    "scripts": {
        "codeceptjs": "codeceptjs run --steps",
    },
    "devDependencies": {
        "codeceptjs": "3.5.5",
        "playwright": "1.35.1"
    }
}
This issue was closed.
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.

1 participant