Getting the error of invalid slection: Unable to locate an element with the xpath expression as following xpath is in valid.
private @FindBy(xpath = "//h1[contains(text(), 'Discover World')]")
WebElement elementSearch;
I even tried with using normalize-space, but with no luck. The action is simple, extract and test out whether the element assigned with the xpath above isDisplayed via Boolean.
The method with the implementation:
public Boolean elementText(WebElement element) {
getDriver().findElement(By.xpath(String.valueOf(element)));
System.out.println("Status of Element present " + element.isDisplayed());
return null;
}
The method calling this implementation:
public void verifyPageLaunched() {
elementText(elementSearch);
}
All actions results in invalid xpath expression error only when running the test on the browser but while manually checking the xpath on browser 'inspect' - it trigger's the right element. Also checked but the above element is not within any iframe either.
Any suggestions what could be triggering this? Thanks team