codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.11k stars 724 forks source link

Facing issues in fetch the element with data-testid #4295

Closed vsblabs closed 6 months ago

vsblabs commented 6 months ago

What are you trying to achieve?

With the latest release v3.6.0, I'm facing issue in fetching the element with data-testid

Its working fine in the earlier version i.e v3.5.15.

Details

'use strict'

const { setHeadlessWhen } = require('@codeceptjs/configure')

setHeadlessWhen(process.env.HEADLESS)

exports.config = {
  tests: './codecept/PROJECT_NAME/tests/*.spec.js',
  output: './codecept/cdk/screenshots',
  helpers: {
    Playwright: {
      url: process.env.TEST_ENVIRONMENT_URL,
      show: true,
      browser: 'chromium',
      windowSize: '1200x900',
      restart: true,
      chrome: {
        ignoreHTTPSErrors: true
      },
      timeout: 100000
    },
    TabsHelper: {
      require: './codecept/PROJECT_NAME/utils/tabHelper.js'
    }
  },
  include: {
    I: './codecept/steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'PROJECT_NAME'
}
vsblabs commented 6 months ago

Supporting screenshots:

Screenshot 2024-04-11 at 9 21 13 PM Screenshot 2024-04-11 at 9 21 30 PM

Sample code used:

   I.waitForElement('button[data-testid="ELEMENT_ID1"]', 5)
   I.click('button[data-testid="ELEMENT_ID2"]')

Expectation: The previously configured test must not fail since this is a minor version upgrade.

DavertMik commented 6 months ago

Sorry for this regression.

@kobenguyent maybe you have any ideas on this? Probably this is not related to my changes. What could have affected this

kobenguyent commented 6 months ago

We introduced the PW locator in this PR. https://github.com/codeceptjs/CodeceptJS/pull/4255.

Would be nice to provide us the more info/logs so that we could understand the big picture better.

vsblabs commented 6 months ago

@kobenguyent

Here is the log that I have seen, for your notice.

 Test case name:
     element (button[data-testid="create-connector-action"]) still not present on page after 5 sec
locator.waitFor: DOMException: Failed to execute 'querySelectorAll' on 'Document': '[object Object]' is not a valid selector.
    at query (<anonymous>:3352:41)
    at <anonymous>:3362:7
    at SelectorEvaluatorImpl._cached (<anonymous>:3139:20)
    at SelectorEvaluatorImpl._queryCSS (<anonymous>:3349:17)
    at SelectorEvaluatorImpl._querySimple (<anonymous>:3229:19)
    at <anonymous>:3177:29
    at SelectorEvaluatorImpl._cached (<anonymous>:3139:20)
    at SelectorEvaluatorImpl.query (<anonymous>:3170:19)
    at Object.query (<anonymous>:3384:44)
    at <anonymous>:3342:21
Call log:
  - waiting for locator('[object Object]').first()
  Error: element (button[data-testid="create-connector-action"]) still not present on page after 5 sec
  locator.waitFor: DOMException: Failed to execute 'querySelectorAll' on 'Document': '[object Object]' is not a valid selector.
      at query (<anonymous>:3352:41)

Thanks in advance.

kobenguyent commented 6 months ago

@kobenguyent

Here is the log that I have seen, for your notice.

 Test case name:
     element (button[data-testid="create-connector-action"]) still not present on page after 5 sec
locator.waitFor: DOMException: Failed to execute 'querySelectorAll' on 'Document': '[object Object]' is not a valid selector.
    at query (<anonymous>:3352:41)
    at <anonymous>:3362:7
    at SelectorEvaluatorImpl._cached (<anonymous>:3139:20)
    at SelectorEvaluatorImpl._queryCSS (<anonymous>:3349:17)
    at SelectorEvaluatorImpl._querySimple (<anonymous>:3229:19)
    at <anonymous>:3177:29
    at SelectorEvaluatorImpl._cached (<anonymous>:3139:20)
    at SelectorEvaluatorImpl.query (<anonymous>:3170:19)
    at Object.query (<anonymous>:3384:44)
    at <anonymous>:3342:21
Call log:
  - waiting for locator('[object Object]').first()
  Error: element (button[data-testid="create-connector-action"]) still not present on page after 5 sec
  locator.waitFor: DOMException: Failed to execute 'querySelectorAll' on 'Document': '[object Object]' is not a valid selector.
      at query (<anonymous>:3352:41)

Thanks in advance.

thanks for the info! We addressed the issue.

vsblabs commented 5 months ago

@kobenguyent Facing the same issue again while upgrading the version. Seems the issue persists.