question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QuerySelector returns null for selector

See original GitHub issue

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Description

We have a site with a list of datasets on it: https://trudvsem.ru/opendata/datasets

I can use a selector #dataset-10 .table__wrapper .link to find some download url on the site.

Element exists and can be found through standard document.querySelector APIs in JS:

image

Also checked this with jsoup in Java and bs4 in python, everything works.

Howewer, in AngleSharp it simply doesn’t work at all and returns null:

image

Steps to Reproduce

  1. Create a console project
  2. Install AngleSharp
  3. Query element with selector above

Or just simply check the demo code in my repository https://github.com/readonlyden/anglesharp-bug-demo

Expected behavior: Element is returned correctly and I can check it href attribute

Actual behavior: QuerySelector returns null

Environment details: .NET 6, Windows

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FlorianRapplcommented, Jun 22, 2022

You compare two different things. See what Anglesharp received from the server. Instead of looking at postman you should look at Anglesharp.

0reactions
FlorianRapplcommented, Jun 26, 2022

As long as there is no MWE to reproduce there is nothing we investigate. The code right now uses an URL and when I go there I don’t see any table / get the same behavior in chrome that you describe as a bug.

So if you really think this is an issue please make a reproducible MWE. Happy to look into it when we have some code showing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The document.querySelector returns null but element exists
querySelector () will return the first element that matches the specified group of selectors. If no match is found 'null' is returned.
Read more >
document.querySelector(...) is null error - javascript
It's saying it's null because the selector passed to document.querySelector() isn't returning an element/node upon which to work. Can you verify ...
Read more >
document.querySelector returns null for existing element
Current behavior: Cypress cannot find an element which exists on the page and is visible. Actually, document.querySelector also does not ...
Read more >
Avoid Errors With document.querySelector and ...
When querySelector doesn't find a matching selector, the value of the variable will be null . For example: var missingElement = document.
Read more >
querySelector returns Null or undefined for childNodes
Hi All,. I'm trying to generate highcharts using JS script passed through client action. I have certain containers on screen (in nested ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found