Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get the correct XPath for a column title using C# and selenium webdriver?

I have the following HTML

<label class="ms-Label headerText-269" title="Reference Id">Reference Id</label>

which I am trying to locate using XPath. I have written the following which doesn’t seem to work.

driver.FindElement(By.XPath("//title[contains(text(),'Reference Id']"));

Any help would be appreciated.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks

>Solution :

Try the below

driver.FindElement(By.XPath("//label[contains(text(),'Reference Id']"));

OR

 driver.FindElement(By.XPath("//*[normalize-space()='Reference Id']"));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading