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 =…

Alexis AG
- 105
- 1
- 5
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…

Keith Bailey
- 43
- 1
- 4
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…

Terence Larson
- 43
- 3
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 -…

Norfeldt
- 8,272
- 23
- 96
- 152
3
votes
1 answer
How to skip a row in Excel with missing html tag using VBA
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…

Jasco
- 225
- 3
- 8
3
votes
1 answer
Cannot get querySelectorAll to work with puppeteer (returns undefined)
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…

Kasper Hansen
- 6,307
- 21
- 70
- 106