2

I am using Selenide 5.6.0 and Junit5 5.5.2 (in the context of Selenium-Jupiter)

When I configure my test class like so:

@ExtendWith({SeleniumExtension.class, ScreenShooterExtension.class})

Then I get this error showing up in the log:

ScreenShotLaboratory - Cannot take screenshot because browser is not started

During the test, I have a step that calls:

screenshot(FILE_STEP1);

Then I have another step called:

screnshot(FILE_STEP2);

If I put a break point before the 2nd screenshot , and after the 1st, the code says my browser is still open:

((LazyDriver)sd.driver).browserHealthChecker.isBrowserStillOpen(sd.getWebDriver())
 // returns true

Therefore I am not understanding why this is saying this. Is there an example project somewhere that I can compare with or is this a regression?

djangofan
  • 28,471
  • 61
  • 196
  • 289

1 Answers1

0

ScreenShooterExtension is a JUnit5 Extension.

It implements AfterEachCallback, which gets executed after the test.

screenshot() is a Selenide function for taking screenshots. It in no way depends on ScreenShooterExtension, can be called separately and plays no role in your getting error message.

So, chances are, you close the Webdriver after the test is executed, so ScreenShooterExtension cannot do anything.

The following picture shows order of execution of Extension callbacks and Junit Annotations like @BeforeEach etc. (Picture taken from here) enter image description here

liaombro
  • 111
  • 3