serenity-bdd / serenity-cucumber-starter

A skeleton project for Serenity BDD and Cucumber JVM
Apache License 2.0
180 stars 285 forks source link

Driver is not instantiate #100

Open MikeAdams11 opened 1 year ago

MikeAdams11 commented 1 year ago

Hi all, Mike here. I would like to share with you an issue that I have that is blowing my mind.

A bit of context, I have automated a web application using @FindBy strategy for the webElements. We use jenkins with this code and it works fine, no issues here. But now, I'm jumping from @FindBy and webElements to use locators BY. After updating the whole selectors of the project, when I execute the jobs for triggering test automation, then I have a very strange issue which is that the driver is not instantiated randomly.

So my problem is that I have a timeoutexeption org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of (tried for 10 second(s) with 500 milliseconds interval) As you can see, even in the stacktrace it's waiting for something that is not there, you can verify there is an empty space when the selector should be.

This issue happens locally as well but im not able to get anything from it. If I execute via jenkins, I'm able to see what is happening using LOG information (thats how i know that driverIsInstantiated() returns FALSE). I have tried to create a new ChromeDriver after it didnt fix tje issue. seems like im not able to "attach" the session to that driver.

I dont know what is happening but the issue is that the browser is never opened, that's for sure. I suppose it can be serenity because if i create my own driver and i dont use the @Managed annotation, it works perfectly.

This is the stack trace i have with the error but i think is not really helpful as its about the waitElement

10:05:30 org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of (tried for 10 second(s) with 500 milliseconds interval) 10:05:30 Build info: version: '4.6.0', revision: '79f1c02ae20' 10:05:30 System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.0-9-amd64', java.version: '11.0.6' 10:05:30 Driver info: net.thucydides.core.webdriver.DevToolsWebDriverFacade 10:05:30 at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:87) 10:05:30 at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:231) 10:05:30 at framework.utils.Utils.waitForConditionVisibility(Utils.java:241) 10:05:30 at framework.utils.Utils.clicker(Utils.java:117) 10:05:30 at framework.pages.Page.accessToEntityListingPage(AnyPage.java:281) 10:05:30 at framework.steps.Steps.accessToEntity(AnySteps.java:112) 10:05:30 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:05:30 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 10:05:30 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 10:05:30 at java.base/java.lang.reflect.Method.invoke(Method.java:566) 10:05:30 at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:790) 10:05:30 at org.jbehave.core.embedder.PerformableTree$FineSoFar.run(PerformableTree.java:349)

POM `

3.4.3 1.46.0 3 chrome com.google.guava guava 31.1-jre net.serenity-bdd serenity-core ${serenity.core.version} net.serenity-bdd serenity-jbehave ${serenity.jbehave.version} junit junit 4.13.2 org.slf4j slf4j-simple 2.0.5 org.apache.commons commons-configuration2 2.8.0 org.hamcrest hamcrest-library 2.2 test ${environment.filter} src/test/resources false src/test/resources-filtered true org.apache.maven.plugins maven-compiler-plugin 3.10.1 1.8 1.8 org.apache.maven.plugins maven-surefire-plugin 3.0.0-M7 org.apache.maven.plugins maven-failsafe-plugin 3.0.0-M7 org.apache.maven.surefire surefire-junit4 3.0.0-M7 **/story/*.java -Xmx1024m ${webdriver.driver} ${parallel.tests} false suitesAndClasses ${parallel.tests} false integration-test verify net.serenity-bdd.maven.plugins serenity-maven-plugin ${serenity.core.version} ${project.build.directory}/site/serenity ${project.build.directory}/site/serenity serenity-reports post-integration-test aggregate ` So a quick resume: - With @FindBy it works fine - With By it doesn't work - Browser is not opened but the test case tries to do his stuff - driverIsInstantiated() == false - Using custom driver instead of Serenity @Managed works fine - Not much info retrieved from the execution Thank you for your support and sorry for the poor explanation, but i think its all I have