I have a piece of code which gets a web element and checks if the element is displayed or not.
Code:
WebElement element = getDriver().findElement(By.linkText("Expand"));
if(element.isDisplayed()){
printInfo("Expand is displayed");
}
else{
printInfo("Expand is NOT displayed");
}
This same piece of code works fine on my local machine on the same environment (prints "Expand is displayed"). However, on the remote machine (using Jenkins), with the same code on the same environment, it fails and executes the else block (prints "Expand is NOT displayed").
I can visually see the element being displayed on the application during execution and there is no issue of synchronization either.
Why is the same piece of code behaving differently on a different machine when it is the same environment?
OS on both the machines: MacOS.
Browser on both the machines: Firefox.