I'm having some trouble getting Selenium to find a button by it's class, within several other elements, the top one having an id.
Markup:
<li>
<input data-e2e-selector="beslotningsstotte-ja" class="hb-radiobutton id="beslutningsstotte-0-0" value="NEI">
<div class="hb-label>
<label class="hb-label-tekst" id="beslutningsstotte-0-0-NEI-label" for="beslutningsstotte-0-0"> Nei
<hb-hjelpetekst>
<div class="hb-hjelpetekst">
<button type="button" class="hb-hjelpetekst-knapp">
<span id="bd9e3ac7-d2cb-45ee-8f2a-e2a57cec87a1-hjelptekst-knapp"><span translate="">Åpne hjelpetekst</span></span>
<hb-ikon ikonid="hb-question-mark" storrelse="" id="hb-question-mark-60b067d7-978d-4a6f-ac66-e2ec402e5b78" class="hb-ikon hb-ikon-- hb-ikon--hb-question-mark">
<svg focusable="false"><use xlink:href="assets/sprite.symbol.svg#ikon-hb-question-mark"></use></svg>
</hb-ikon>
</button><div _ngcontent-mep-c50="" role="tooltip" aria-hidden="false" aria-live="polite" class="hb-hjelpetekst-innhold hb-hjelpetekst--utvidet-ontop"><div _ngcontent-mep-c50=""
The element I'm trying to access is the <button type="button" class="hb-hjelpetekst-knapp">, which has a with a dynamic ID which cannot be used.
So, I thought to give ByChained() a try:
this.element.findElement(new ByChained(By.id("beslutningsstotte-0-0"), By.className("hb-hjelpetekst-knapp"))).click();
But this gives this error:
org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.chained({By.id: beslutningsstotte-0-0,By.className: hb-hjelpetekst-knapp})
Is my ByChained() specification the problem?
I also tried chaining all the element down to the element:
this.element.findElement(new ByChained(By.id("beslutningsstotte-0-0"), By.className("hb-label"), By.className("hb-label-tekst"),
By.tagName("hb-hjelpetekst"), By.className("hb-hjelpetekst"), By.className("hb-hjelpetekst-knapp"))).click();
Which didn't help, either.
Ideas?