Questions tagged [queryselector]

437 questions
200
votes
2 answers

querySelector vs. getElementById

I have heard that querySelector and querySelectorAll are new methods to select DOM elements. How do they compare to the older methods, getElementById and getElementsByClassName in terms of performance and browser support? How does the performance…
goesToEleven
  • 2,083
  • 2
  • 12
  • 4
11
votes
2 answers

Scraper throws errors instead of quitting the browser when everything is done

I've written a scraper to parse movie information from a torrent site. I used IE and queryselector. My code does parse everything. It throws errors instead of quitting the browser when everything is done. If I cancel the error box then I can see the…
SIM
  • 21,997
  • 5
  • 37
  • 109
8
votes
1 answer

How to extract info within a #shadow-root (open) using Selenium Python?

I got the next url related to an online store https://www.tiendasjumbo.co/buscar?q=mani and I can't extract the product label an another fields: from selenium import webdriver import time from random import randint driver =…
7
votes
1 answer

How can I test inner text of a div element

I'm trying to find the best practice to test textContent for a div element here, using react testing library. Say I'd like to test this simple react component to see if {props.text} is rendered properly on the HTML DOM. const Simple = props => ( …
han
  • 97
  • 1
  • 1
  • 5
5
votes
2 answers

Multiple descendant selectors, bug or misunderstanding?

Shouldn't the following two approaches to selecting a node produce the same result? let tmp = fruits.querySelector("ul:first-of-type li:first-of-type"); tmp = tmp.querySelector("span") vs. let tmp = fruits.querySelector("ul:first-of-type…
Michael Lipp
  • 341
  • 3
  • 8
4
votes
1 answer

Unexpected results using Element.querySelector

Given the following markup (I've only included the relevant part for the sake of brevity)
Zippy
  • 3,826
  • 5
  • 43
  • 96
4
votes
1 answer

What are the currently supported CSS selectors available to VBA?

Back on May 19th 2021, I wrote this Q&A regarding recent (Apr-May-21) suspected changes to an interface in relation to mshtml.dll and late bound referencing. This is a part 2, if you will. Previously, in questions such as this and this, I have…
QHarr
  • 83,427
  • 12
  • 54
  • 101
4
votes
3 answers

QuerySelector with specified index in Javascript (like [1])

How do I make: document.getElementsByClassName("first")[1].getElementsByClassName("second")[2]; but with querySelector? My guess would be: document.querySelector(".first[1] > .second[2]"); But that doesn't work.
Tobias H.
  • 426
  • 1
  • 6
  • 18
4
votes
5 answers

Unable to locate the Sign In element within #shadow-root (open) using Selenium and Python

I'm trying to use selenium to automate some actions but am unable to find the first element on the page https://developer.servicenow.com/dev.do and so cannot login from selenium import webdriver from selenium.webdriver.common.keys import…
4
votes
1 answer

Unable to let my script run through the end

I've written a script in vba using ServerXMLHTTP requests in order to be able to use proxy along with setting timeout parameter within it. When I run the script, it appears to be working but the problem is - it gets stuck after using the first…
robots.txt
  • 96
  • 2
  • 10
  • 36
3
votes
2 answers

How can I select all child elements with a certain class using querySelector in JavaScript regardless of the order they appear in HTML?

I'm working on filtering a directory that's fed through a component created by our CMS, which I have no control over. The tags for each directory member that I'm trying to filter are inside divs with class of d-none. The script I'm using works…
3
votes
2 answers

JavaScript - Get contained text in DOM element in Javascript?

I have a
with some children within and it's contained text like below:
The baby tears the pages of the

books with her hands.

What is the…

Daniel Smith
  • 1,626
  • 3
  • 29
  • 59
3
votes
1 answer

cheeriojs iterate over xml response

Say I have an xml response from a request that looks like this: Live Nyhederne -…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/jquery" class="post-tag grid--cell" title="show questions tagged 'jquery'" rel="tag">jquery</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/cheerio" class="post-tag grid--cell" title="show questions tagged 'cheerio'" rel="tag">cheerio</a> <a href="../../questions/tagged/queryselector" class="post-tag grid--cell" title="show questions tagged 'queryselector'" rel="tag">queryselector</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 06 '21 at 07:45">asked Aug 06 '21 at 07:45</time> <a href="../../users/618099/norfeldt" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/618099.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Norfeldt" /> </a> <div class="s-user-card--info"> <a href="../../users/618099/norfeldt" class="s-user-card--link">Norfeldt</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">8,272</li> <li class="s-award-bling s-award-bling__gold" title="23 gold badges">23</li> <li class="s-award-bling s-award-bling__silver" title="96 silver badges">96</li> <li class="s-award-bling s-award-bling__bronze" title="152 bronze badges">152</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-67860268"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>3</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/67860268/how-to-skip-a-row-in-excel-with-missing-html-tag-using-vba" class="question-hyperlink">How to skip a row in Excel with missing html tag using VBA</a></h3> <div class="excerpt">There are 15 objects listed on this website, each has a link under the photo. The 6th object has none. When extracting and transferring the content with my code the missing html-href is not skipped and in Excel, 14 hrefs are listed below each other…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/excel" class="post-tag grid--cell" title="show questions tagged 'excel'" rel="tag">excel</a> <a href="../../questions/tagged/vba" class="post-tag grid--cell" title="show questions tagged 'vba'" rel="tag">vba</a> <a href="../../questions/tagged/web-scraping" class="post-tag grid--cell" title="show questions tagged 'web-scraping'" rel="tag">web-scraping</a> <a href="../../questions/tagged/xmlhttprequest" class="post-tag grid--cell" title="show questions tagged 'xmlhttprequest'" rel="tag">xmlhttprequest</a> <a href="../../questions/tagged/queryselector" class="post-tag grid--cell" title="show questions tagged 'queryselector'" rel="tag">queryselector</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 06 '21 at 14:39">asked Jun 06 '21 at 14:39</time> <a href="../../users/15428580/jasco" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/15428580.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Jasco" /> </a> <div class="s-user-card--info"> <a href="../../users/15428580/jasco" class="s-user-card--link">Jasco</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">225</li> <li class="s-award-bling s-award-bling__silver" title="3 silver badges">3</li> <li class="s-award-bling s-award-bling__bronze" title="8 bronze badges">8</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-65270869"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>3</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/65270869/cannot-get-queryselectorall-to-work-with-puppeteer-returns-undefined" class="question-hyperlink">Cannot get querySelectorAll to work with puppeteer (returns undefined)</a></h3> <div class="excerpt">I'm trying to practice some web scraping with prices from a supermarket. It's with node.js and puppeteer. I can navigate throught the website in beginning with accepting cookies and clicking a "load more button". But then when I try to read div's…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/puppeteer" class="post-tag grid--cell" title="show questions tagged 'puppeteer'" rel="tag">puppeteer</a> <a href="../../questions/tagged/queryselector" class="post-tag grid--cell" title="show questions tagged 'queryselector'" rel="tag">queryselector</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 12 '20 at 23:20">asked Dec 12 '20 at 23:20</time> <a href="../../users/510731/kasper-hansen" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/510731.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Kasper Hansen" /> </a> <div class="s-user-card--info"> <a href="../../users/510731/kasper-hansen" class="s-user-card--link">Kasper Hansen</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">6,307</li> <li class="s-award-bling s-award-bling__gold" title="21 gold badges">21</li> <li class="s-award-bling s-award-bling__silver" title="70 silver badges">70</li> <li class="s-award-bling s-award-bling__bronze" title="106 bronze badges">106</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/queryselector_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/queryselector_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/queryselector_page=29" rel="" title="Go to page 29">29</a> <a class="s-pagination--item" href="../../questions/tagged/queryselector_page=30" rel="" title="Go to page 30">30</a> <a class="s-pagination--item" href="../../questions/tagged/queryselector_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>