'Can select element in devtools but not puppeteer

I'm working with puppeteer. I want to get the node value of a selected element in a textbox . Using dev tools I have copied the selector:

  var mySelector = "div.chosen-container.chosen-container-multi.filter-main-values.fmd-values.chosen-container-active.chosen-with-drop > ul > li.search-choice > span";

I can use this to find it in devtools:

enter image description here

But after running my puppeteer code:

  var selectedCountry = await page.evaluate((mySelector) => {return Array.from(document.querySelectorAll(mySelector))});
  console.log(selectedCountry);

In the vs code debug window, I see:

(0) []

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source