Skip to content

Issues with tryTo and highlightElement using Playwright #3895

@cjhille

Description

@cjhille

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"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions