I am using Selenium v3.8.0, also I doingdo the coding in C#.
Now I try to validate if XPath or the webElement exists on the site, though I don't success
Now I try to validate the text Login
then I want to alert it in console:
Here is my atemptattempt:
if (IsElementPresent(By.XPath("//h3[@translate='TITLE_LOGIN']")))
{
Console.WriteLine("Element exists");
}
else
{
Console.WriteLine("Element not displayed");
}
private bool IsElementPresent(By by)
{
try
{
Driver.Instance.FindElement(by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
Link to URL: Owasp Juiceshop