Skip to content

[Feature] expose Locator._selector as public #11313

Description

@MartinP-Autopilot

Our framework uses complex modelling such as (example cooked up for this post)

class Table{
  $container: Locator;
  constructor($container: Locator){
    this.$container = $container;
  }
  getRow(index: number):TableRow{
    return new TableRow(this.$container, index);
  }
}

class TableRow{
  $container: Locator;
  constructor($container: Locator, index: number){
    this.$container = $container.locator(`tr >> nth=${index}`);
  }
  async getCellValue(cellIndex: number):string{
    return await this.$container.locator(`td >> nth=${cellIndex}`).innerText();
  }
}

As we've recently found that there are some idiosyncrasies with chaining (e.g. chaining does not result in direct child selectors), it would be good to get the selector from a locator and use it to build the next locator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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