Id defined for radiobuttons
<tr _ngcontent-icx-c221="" class="ng-star-inserted" style=""><td _ngcontent-icx-c221="" style="width: 4rem; border-width: 1px; text-align: center;"><div _ngcontent-icx-c221="" class="flex justify-content-start align-items-center ng-star-inserted"><p-radiobutton _ngcontent-icx-c221="" name="produktRisiko" class="mr-1 ng-untouched ng-pristine ng-valid" ng-reflect-name="produktRisiko" ng-reflect-input-id="produktRisiko_7" ng-reflect-value="8" ng-reflect-model="4"><div ng-reflect-ng-class="[object Object]" class="p-radiobutton p-component"><div class="p-hidden-accessible"><input type="radio" id="produktRisiko_7" name="produktRisiko" value="8" aria-checked="false"></div><div ng-reflect-ng-class="[object Object]" class="p-radiobutton-box"><span class="p-radiobutton-icon"></span></div></div><!--bindings={}--></p-radiobutton><span _ngcontent-icx-c221="" class="flex align-items-center">6</span></div><!--bindings={
"ng-reflect-ng-if": "true"
}--></td><td _ngcontent-icx-c221="" style="border-width: 1px;"> Consequential damage on main parts, (repairable on location with </td></tr>
And my code is:
wait.until(ExpectedConditions.elementToBeClickable(By.id("produktRisiko_7"))).click();
Error:
Expected condition failed: waiting for element to be clickable: By.id: produktRisiko_7 (tried for 50 second(s) with 500 milliseconds interval)
CodePudding user response:
I believe your problem is what I suspected. Your radio button is not clickable because it is disabled (hidden). Your radio button element is surrounded by a div that is hidden:
<div class="p-hidden-accessible">
<input type="radio" id="produktRisiko_7" name="produktRisiko" value="8" aria-checked="false">
</div>
I am not sure what you are trying to do, but you got to figure out why this div
is hidden. Hopefully this give you some insight, but you need to explain your problem better. What are you trying to do? Can you actually see the button on the page? If you cannot see the radio button on the page, you should not attempt to interact with the component using some backdoor mechanism (i.e. invoking a JavaScript command) because the purpose of these tests, I assume, is to test human interaction.
CodePudding user response:
I solved my problem with the following structure. Thank you for your attention
((JavascriptExecutor) driver).executeScript("document.getElementById('produktRisiko_7').click();");