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.

Creating a selector for the element

See original GitHub issue

Does AngleSharp make it able to create a selector for a certain node?

Consider this example:

<html>
	<body>
	<div id="header">
		<span class="decorator">Logo</span>
	</div>
	<div id="container">
		<div>
			<h1>This is a test</h1>
		</div>
                <div>...</div>
	</div>
	</body>
</html>

selectedElement points to <h1> node in the above HTML.

When called: selectedElement.CreateSelector();

Sample output would be the element selector: body > div > div:nth-child(1) > h1

I have slightly browsed the source code, but wasn’t able to find anything for it. I would like be sure however, before making any efforts to implement it myself.

Regards Lucas

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
lvkinscommented, Apr 29, 2019

@cmxl Since id selector is unique, it will do just what @FlorianRappl said. This is perfectly valid.

1reaction
FlorianRapplcommented, Apr 29, 2019

I think it stops when the first id selector is hit, e.g.,

#container > div:nth-child(1) > h1

but yes - that’s also how I see it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Selectors
To select an element with a specific id, write a hash (#) character, followed by the id of the element. Example. The CSS...
Read more >
CSS selectors - Learn web development | MDN
A CSS selector is the first part of a CSS Rule. It is a pattern of elements and other terms that tell the...
Read more >
How To Select HTML Elements Using ID, Class, and ...
Creating Advanced Attribute Selectors. The attribute selector is useful for finding particular attributes in the HTML and applying styles to ...
Read more >
CSS Selectors - GeeksforGeeks
A CSS selector selects the HTML element(s) for styling purposes. CSS selectors select HTML elements according to their id, class, type, ...
Read more >
CSS Selector in Selenium: Locate Elements with Examples
This article will discuss and describe, with examples, how one can use CSS selectors in Selenium test scripts to identify web elements.
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