grafana / xk6-browser

The browser module adds support for browser automation and end-to-end web testing via the Chrome Devtools Protocol to k6.
https://grafana.com/docs/k6/latest/javascript-api/k6-browser/
GNU Affero General Public License v3.0
341 stars 42 forks source link

page.locator('a') not returning all links on page #900

Open tmc opened 1 year ago

tmc commented 1 year ago

Brief summary

I have a situation where iterating over all 'a' tags and printing them produces a different smaller list when run in k6 vs directly in the browser window that is being controlled.

const printAllAnchors = async (page) => {
    const elements = await page.$$('a');
    console.log(elements.length);
    for (let i = 0; i < elements.length; i++) {
      const e = elements[i];
      const text = await e.textContent();
      console.log(text);
    }
}

In k6 this shows 14 anchor tags where as in the chrome tab/console I get 58 anchor tags.

xk6-browser version

v0.44.1

OS

macos

Chrome version

canary latest

Docker version and image (if applicable)

No response

Steps to reproduce the problem

A test that navigates to

https://xxx.sandbox.lightning.force.com/lightning/r/Contact/0037A00000oo1nuQAA/view

Expected behaviour

the list of anchor tags is complete.

Actual behaviour

This list of anchor tags is many fewer than a direct query in the same chrome tab.

tmc commented 1 year ago

I think this is a dupe of https://github.com/grafana/xk6-browser/issues/475