I'm trying to query a complex web app for some data...
A very simplified example is the below
<section class="Test newTest testTest active">
<div>
</div>
<a class="classLink1 classlink2 classlink3" data-render="test">Link</a>
</div>
</div>
</section>
<section class="Test newTest testTest">
<div>
</div>
<a class="classLink1 classlink2 classlink3" data-render="test">Link</a>
</div>
</div>
</section>
Problem
<a> tags with very similasr class names and some dataset with unique values which I don't want to query<a> tag where the parent <section> has an .active class. But it may not be the immediate parent if that makes senseI am trying something like this
document.querySelectorAll('section.Test.newTest.testTest.active a.classLink1.classlink2.classlink3 [data-render="test"]')
But it seems to return an empty nodelist.
You must not have the space between classlink3 and [data-render="test"], as the elements you are searching for have both classes and attribute, and aren't nested inside the "classes" element.
The right selector should be
'section.Test.newTest.testTest.active a.classLink1.classlink2.classlink3[data-render="test"]'
Which will select the following
Instead of