I’m assuming that the ID of the you’re seeking is not static and you have no better way to locate the than to find it by the text “Active” then move up and then down the to locate it.

The key parts of your HTML appear to be:

<div>
    <label>
        <span>Active
        </span>
    </label>
    <input type="checkbox" checked="checked" defaultchecked="true" id="2202:0" data-aura-rendered-by="2206:0" data-interactive-lib-uid="11">
</div>

If there will only ever be one checkbox in the div that contains the Active span, then you are safe to do something like this (C#-ish syntax, pseudocode):

element parent = driver.findElement(By.Xpath(//div[contains(text(), 'Active')]"));
element checkbox = parent.findElement(By.tagName("input"));

This method will work as long as there is exactly one div on the page with the text Active somewhere in the innerText, exactly one input in the div, and the one input is always of type checkbox.



Source link https://sqa.stackexchange.com/questions/34787/how-to---on-dom-without-using-element-name

LEAVE A REPLY

Please enter your comment!
Please enter your name here