Open anshuman-sdet opened 2 months ago
I encountered the same issue, the difference is just on the version, for me everything work well with version 4.1.6 and nothing works with the newer version (> 4.1.6). Seems like there's an issue with @FindBy initialization.
cc: @wakaleo
Also encountering this issue. Downgrade to 4.1.6 fixes the issue. Thanks @skarindra!
Using Java 21 here. Hopefully a fix can be made for 4.2.x
If you need this fix quickly the best thing would be to propose a PR or request a fix as part of a commercial support contract.
What happened?
I am trying to upgrade to serenity version 3.9.8 so that I can make use of parallel execution using Junit 5. The application is being launched fine which means that the getDriver() object is working fine. However, when an element is being looked up by using @FindBy, the WebElementFacade is not being initialized and throws below error: java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebElement.isDisplayed()" because "this.element" is null at org.openqa.selenium.support.ui.ExpectedConditions.elementIfVisible(ExpectedConditions.java:304) at org.openqa.selenium.support.ui.ExpectedConditions$10.apply(ExpectedConditions.java:290) at org.openqa.selenium.support.ui.ExpectedConditions$10.apply(ExpectedConditions.java:287) at org.openqa.selenium.support.ui.ExpectedConditions$23.apply(ExpectedConditions.java:656) at org.openqa.selenium.support.ui.ExpectedConditions$23.apply(ExpectedConditions.java:652) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:203) at net.serenitybdd.core.pages.RenderedPageObjectView.waitFor(RenderedPageObjectView.java:110) at net.serenitybdd.core.pages.PageObject.waitFor(PageObject.java:417)
Also tried to update to latest Serenity version 4.1.20 but the result is exactly the same. Everything works fine when using the earlier version 3.6.22. When using getDriver().findElement, it's working perfectly fine on both 3.9.8 and 4.1.20. The issue is only when using @FindBy annotation.
What did you expect to happen?
The WebElementFacade should not be null when using @FindBy and interactions with the elements should happen.
Serenity BDD version
serenity-core, serenity-junit, serenity-cucumber, serenity-rest-assured, serenity-single-page-report - 3.9.8 & 4.1.20
JDK version
17
Execution environment
Win 11
How to reproduce the bug.
Upgrade to latest version of Serenity 4.1.20 from 3.6.22. Have the PageFactory to find the elements using @FindBy annotation.
How can we make it happen?
Add it to the Serenity BDD backlog and wait for a volunteer to pick it up