automationplaywright

playwright find child element(s) within locator


I'm trying to write a function to find child(ren) element(s) within a locator something like:

async findElements(locator: Locator){
  return locator.querySelector(some/xpath/or/css);
}

However, I'm seeing the querySelector is not available in Locator. What is the equivalent of querySelector?


Solution

  • I figured it out,

    locator.locator(some/xpath/)
    

    Update:

    or

    locator.locator(some_locator)