Issue: I am seeing difficulty to handle checkbox of Salesforce page. I am not seeing any difference between two state of Checkbox. Both state checked and non-checked are showing same classes, attributes and text. I am not sure how to handle the checkbox on Salesforce. Please see below screenshot. We do have Ids but they are dynamic so I can not use IDs in my test case.
Platform: JAVA, TestNG, Eclipse, Selenium
Only difference I see is when checkbox is selected then I can see below:
<span lightning-input_input="" class="slds-checkbox_faux" xpath="1">
: : after ==$0
</span>
when it's not checked the I can see below:
<span lightning-input_input="" class="slds-checkbox_faux" xpath="1">
</span>
What I tried so far which is not helping me on Salesforce page:
String rr = driver.findElement(xpath).getAttribute("checked"); // not working
isSelected(); // Not Working
document.getElementById('myInput').checked // Can not use this becasue of Dynamic ID
Below links I have gone through and tried locally on Salesforce page:
Selenium checkbox attribute "checked"
Xpath to determine checkbox "checked" attribute in Selenium IDE