I have the following html:
<p class="k-reset"><a class="k-icon k-i-expand" href="#" tabindex="-1"></a>Unit: QA Room: 1</p>
I can't seem to get valid syntax to click on this element. I've tried the following:
IWebElement webElement5 = Driver.Instance.FindElement(By.XPath("//a[@class='k-icon k-i-expand']"));
webElement5.Click();
IWebElement webElement5 = Driver.Instance.FindElement(By.XPath("//p[text(), 'Unit: QA Room: 1']"));
webElement5.Click();
When I try to use the text(), I get an error stating that it is not a valid XPath expression. Everywhere I look on the internet uses that syntax. I'm very new to c#/Selenium/XPath values. Any help is very much appreciated.
//p[.='Unit: QA Room: 1']. If you want text contains then you want//p[contains(., 'Unit: QA Room: 1')]. You seem to be mixing the two... replace the,with a=and it should be valid.