codeceptjs / CodeceptJS

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

wait* steps not works with arguments {name | id } #2469

Open Vorobeyko opened 4 years ago

Vorobeyko commented 4 years ago

I try to call:

I.waitForVisible({ name: 'field_name' })

but locator contains:

Locator {
  type: 'name',
  output: null,
  strict: true,
  locator: { name: 'field_name' },
  value: 'field_name'
}

And the waitForVisible step checks if this locator isCss will make locator.simplify, else waitByXpath, but name is not css, and CodeceptJS tries to search element by following xpath: 'field_name', but it is invalid xpath

swtech-11 commented 3 years ago

A workaround is explicitly declaring your locatorObj type to 'css'. Working example:

module.exports = () => {
    codeceptjs.locator.addFilter(( providedLocator, locatorObj) => {
        if (...) {
            locatorObj.type = 'css';
            ...