I'm trying to find the XPATH or CSS locator for a checkbox in an HTML span tag that has a label with specific text, like "Allow gender mismatch". I can locate the label using XPATH, but I'm not sure how to target the input tag so I can click on the checkbox.
Unfortunately, I can't use id="gwt-uid-1204" as it's a dynamic value that changes each time the page is visited.
The XPATH to get the label text is:
//div[@id="match_configuration_add_possible_tab_match_rules_fp_flags"]/span/label[contains(text(), "Allow gender mismatch")]
Here is an example of the HTML snippet:
<div id="match_configuration_add_possible_tab_match_rules_fp_flags">
<div class="gwt-Label matchruleheader">Gender and title flags</div>
<span class="gwt-CheckBox" style="display: block;">
<input id="gwt-uid-1204" type="checkbox" value="on" tabindex="0"/>
<label for="gwt-uid-1204">Gender must be present in both names</label>
</span>
<span class="gwt-CheckBox" style="display: block;">
<input id="gwt-uid-1205" type="checkbox" value="on" tabindex="0"/>
<label for="gwt-uid-1205">Gender must be consistent in both names</label>
</span>
<span class="gwt-CheckBox" style="display: block;">
<input id="gwt-uid-1206" type="checkbox" value="on" tabindex="0"/>
<label for="gwt-uid-1206">Allow gender mismatch</label>
</span>
<span class="gwt-CheckBox" style="display: block;">
<span class="gwt-CheckBox" style="display: block;">
<span class="gwt-CheckBox" style="display: block;">
-- More checkboxes
</div>
If anyone can assist with finding the correct XPATH or CSS locator for this scenario, I would greatly appreciate it. Thank you! - Riaz