I have following HTML code
<div class="compatible-product ng-star-inserted"> <adapt-checkbox2 class="checkbox ng-valid ng-star-inserted ng-dirty ng-touched" ng-reflect-model="false"> <label class="checkbox__label" for= "adapt-checkbox-453-input"> <input class="checkbox__input" type="checkbox" id="adapt-checkbox-453-input" tabindex="0" aria-label="" aria-checked="false">
<span class="checkbox__item">
<span class="sr-only" ng-reflect-ng-class="[object Object]"></span> </span> </label> </adapt-checkbox2> <span class="compatible-product-name" style="">Product - ABC</span> </div> <div class="compatible-product ng-star-inserted"> <adapt-checkbox2 class="checkbox ng-untouched ng-pristine ng-valid ng-star-inserted"> <label class="checkbox__label" for="adapt-checkbox-454-input"> <input class="checkbox__input" type="checkbox" id="adapt-checkbox-454-input" tabindex="0" aria-label="" aria-checked="false"> <span class="checkbox__item">
<span class="sr-only" ng-reflect-ng-class="[object Object]"></span> </span> </label> </adapt-checkbox2>
<span class="compatible-product-name" style="">Product - XYZ</span> </div>
From which 1) First I need to select/click on "adapt-checkbox2" who is left to Span "Product - ABC" So I have written code as follows
WebElement selectCompatibleProduct1 = driver.findElement(RelativeLocator.withTagName("adapt-checkbox2").toLeftOf(By.xpath("//*[text()='Product - ABC']")));
selectCompatibleProduct1.click();
Which is working fine. Its selecting the correct check-box.
2) But Whenever I tried to select 2nd check-box its not working. Its again clicking/selecting 1st checkbox. Code for 2nd checkbox is:-
WebElement selectCompatibleProduct2 = driver.findElement(RelativeLocator.withTagName("adapt-checkbox2").toLeftOf(By.xpath("//*[text()='Product - XYZ']")));
selectCompatibleProduct2.click();
Selenium Version is:- 4.0.0-alpha-3 Please can someone help me on this? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire