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
343 stars 41 forks source link

Include more debug information in waitForSelector timeout exception #181

Closed tom-miseur closed 2 years ago

tom-miseur commented 2 years ago

When a selector cannot be located, we currently print wait for selector didn't resulted in any nodes. When it happens, it is very useful to know which selector the error message refers to.

A simple fix that also corrects the grammar (resulted -> result):

return nil, errors.New("wait for selector didn't result in any nodes. selector: " + selector)

As this will likely be a very common exception, it may be worth thinking about what else we can include in it, such as a suggestion for why an element may not have been found.

inancgumus commented 2 years ago

@tom-miseur

Yeah, agreed. I’ll work on this Monday.

By the way, you can use:

XK6_BROWSER_LOG=debug xk6 run

Even for more info, you can use: XK6_BROWSER_LOG=trace

inancgumus commented 2 years ago

@tom-miseur This minor feature is ready to be served.