The below function is what I have been using to check texts on web pages, but the function fails to find text put under 'br' tag. Kindly advice.
C#:
public static IWebElement CheckTextOnPage(IWebDriver driver, string _text)
{
var buildXpath = "//*[contains(translate(text()[normalize-space()],'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), '" + _text.ToLower() + "' )]";
return driver.FindElement(By.XPath(buildXpath));
}
Sample Html:
<html>
<div>
Test string 1.
<br>Test string 2.
<br>Test string 3.
</div>
</html>
_text.ToLower()what value this is ? if your value isTest string 2.this won't work?//text()[normalize-space()][contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), '" + _text.ToLower() + "' )]/parent::*