I am working on a project. In that, I am trying to find the preceding element using selenium webdriver with the use of xpath selector. I’m selecting a label using xpath but it returns the null value using below code line
driver.FindElement(By.XPath("//*[@id='myDvId']/label/preceding-sibling::input[1])"));
Below is the HTML:
<div id="myDvId">
<input type="checkbox" id="chxInputId"></input> <!-- THIS IS INPUT CHECKBOX WITH NO ID or CLASS NAME -->
<label for="chxInputId">My Label<label>
</div>
Please help me in this