Skip to content

Commit

Permalink
Enhance waitForSelector js error message
Browse files Browse the repository at this point in the history
waitForSelector may result in a confusing error message:

        selector did not resolve to any element

We're now explaining which selector didn't resolve to an element.
  • Loading branch information
inancgumus committed Oct 4, 2024
1 parent 61d4228 commit f156cc2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions common/js/injected_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,6 @@ class InjectedScript {

waitForSelector(selector, root, strict, state, polling, timeout, ...args) {
let lastElement;
let previewNode = this.previewNode;
const predicate = () => {
const elements = this.querySelectorAll(selector, root || document);
const element = elements[0];
Expand All @@ -993,7 +992,7 @@ class InjectedScript {
if (lastElement !== element) {
lastElement = element;
if (!element) {
console.log(` selector did not resolve to any element`);
console.log(` ${selector} did not match any elements`);
} else {
if (elements.length > 1) {
if (strict) {
Expand Down

0 comments on commit f156cc2

Please sign in to comment.