Skip to content

Nested locator with first()  #2061

@TempleOfTemplar

Description

@TempleOfTemplar

What are you trying to achieve?

Get first element with attr tid="device" inside block with attr tid="requesting-devices-list", using following selector: locate("[tid=requesting-devices-list] [tid=device]").first()

  • (also i tried to use: locate({tid: 'device'}).inside({tid: 'requesting-devices-list'}).first() , cause i have custom selector "tid=..." in config)

What do you get instead?

Error: 
XPath with round brackets is not possible here! May be a nested locator with at() last() or first() causes this error.
locate("[tid=requesting-devices-list] [tid=device]").first()

Details

  • CodeceptJS version: 2.3.6.
  • NodeJS Version: 12.1.0
  • Operating System: Windows
  • puppeteer 2.0.0
  • Configuration file:
exports.config = {
  tests: './testing/tests/*_test.js',
  output: './testing/output',
  helpers: {
    Puppeteer: {
      url: 'https://localhost:4204',
      show: true,
      restart: false,
      waitForNavigation: ["domcontentloaded", "networkidle2"]
    },
    MockRequest: {},
  },
  include: {
    I: './testing/steps_file.js',
    deviceManagerPage: './testing/pages/DeviceManagerPagePo.js',

  },
  bootstrap: function (done) {
    codeceptjs.locator.addFilter((providedLocator, locatorObj) => {
      if (providedLocator.tid) {
        locatorObj.type = 'css';
        locatorObj.value = `*[tid="${providedLocator.tid}"]`;
      }
    });
    done();
  },
  mocha: {},
  name: 'TestApp',
  translation: 'ru-RU'
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions