serenity-bdd / serenity-junit-starter

Apache License 2.0
53 stars 87 forks source link

Chrome processes are starting to remain open in the background and also stack up, consuming more and more CPU #39

Closed bnx9908 closed 8 months ago

bnx9908 commented 10 months ago

Hello!

So, I'm using this pom.xml:

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>group</groupId>
<artifactId>artifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
    <encoding>UTF-8</encoding>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <serenity.version>4.0.28</serenity.version>
    <junit5.version>5.10.0</junit5.version>
    <logback-classic.version>1.4.14</logback-classic.version>
    <assertj-core.version>3.24.2</assertj-core.version>
    <maven-surefire-plugin.version>3.2.1</maven-surefire-plugin.version>
    <maven-failsafe-plugin.version>3.2.1</maven-failsafe-plugin.version>
    <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
    <tags></tags>
    <webdriver.base.url></webdriver.base.url>
</properties>
<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit5</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-rest-assured</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit5.version}</version>
        <scope>test</scope>
    </dependency><dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit5.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback-classic.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${assertj-core.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <configuration>
                <includes>
                    <include>**/*Test.java</include>
                    <include>**/Test*.java</include>
                    <include>**/*TestSuite.java</include>
                    <include>**/When*.java</include>
                </includes>
                <systemPropertyVariables>
                    <junit.jupiter.extensions.autodetection.enabled>true</junit.jupiter.extensions.autodetection.enabled>
                </systemPropertyVariables>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <source>21</source>
                <target>21</target>
                <compilerArgs>
                    <arg>-parameters</arg>
                </compilerArgs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.version}</version>
            <configuration>
                <tags>${tags}</tags>
                <reports>single-page-html</reports>
            </configuration>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-single-page-report</artifactId>
                    <version>${serenity.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

Problem:

They appear under the IntelliJ process and also separately, as in the screenshot below:

image

Please have a look at some point. Pretty please! ^.^ It's annoying always to keep an eye on the Windows processes and have to kill them manually.

Thank you very much!

bnx9908 commented 10 months ago

😒

image

wakaleo commented 10 months ago

I am unable to reproduce this, it may be some kind of chromedriver or JVM-related issue.

bnx9908 commented 10 months ago

I am unable to reproduce this, it may be some kind of chromedriver or JVM-related issue.

I really don't know what to do 😞 I have uninstalled everything that is not needed, but it continues occurring 😞 With just a random step commented so that the Test fails, the chrome processes start stacking after 1st try even.

It doesn't seem to happen if the Test is successful.

I don't even know what else to try 😞

wakaleo commented 10 months ago

Try putting breakpoints in the closeAndQuit() method in WebDriverInstances class and closeWhenTheTestsAreFinished() in the WebdriverCloseBrowser class and see what is happening when these methods are called. They call the Selenium quit() method which should shut down chromedriver. If the chromedriver remains after this call, the problem is probably with chromedriver or Windows.

bnx9908 commented 10 months ago

Try putting breakpoints in the closeAndQuit() method in WebDriverInstances class and closeWhenTheTestsAreFinished() in the WebdriverCloseBrowser class and see what is happening when these methods are called. They call the Selenium quit() method which should shut down chromedriver. If the chromedriver remains after this call, the problem is probably with chromedriver or Windows.

Thank you for your support, I really appreciate it. πŸ™‡

But I'm not using any WebDriverInstances, WebdriverCloseBrowser classes. I let Serenity do all the chrome driver jobs.

I even tried it on a different computer, with different Windows, and the chrome processes are starting to stick and stack very quickly as well 😞

Another thing would be that in headless mode (ON) the issue never happens.

wakaleo commented 10 months ago

I suspect it might be a Windows or Chrome-specific issue. The purpose of putting breakpoints in the Serenity classes is to confirm that the quit() method is effectively called. If the quit() method is invoked but the process is not ending, it is probably a chromedriver or Windows-related issue.

bnx9908 commented 10 months ago

I suspect it might be a Windows or Chrome-specific issue. The purpose of putting breakpoints in the Serenity classes is to confirm that the quit() method is effectively called. If the quit() method is invoked but the process is not ending, it is probably a chromedriver or Windows-related issue.

I tried my best to understand and apply your request. I'm a beginner, so probably is not entirely correct what I did, but:

image

So is there anything that can be done in case it is a Windows or Chrome specific issue?

wakaleo commented 10 months ago

I suspect it might be a Windows or Chrome-specific issue. The purpose of putting breakpoints in the Serenity classes is to confirm that the quit() method is effectively called. If the quit() method is invoked but the process is not ending, it is probably a chromedriver or Windows-related issue.

I tried my best to understand and apply your request. I'm a beginner, so probably is not entirely correct what I did, but:

  • when debugging
  • after driver.quit() was successfully run -> ("Uninitialised WebDriverFacade")
  • the browser automatically closed
  • but the process kept running in the background

image

So is there anything that can be done in case it is a Windows or Chrome specific issue?

So that demonstrates that it is a chromedriver-related issue, so the best would be to ask the chromedriver developers.

bnx9908 commented 10 months ago

Tough outcome, but I tried:

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4672

Thank you, Mr Ferguson! <3

wakaleo commented 10 months ago

Also see if you can reproduce the behaviour with a plain Selenium test

bnx9908 commented 10 months ago

Also see if you can reproduce the behaviour with a plain Selenium test

The issue is reproducible with plain Selenium too:

image

wakaleo commented 10 months ago

This might indicate that it is either a Selenium issue (very unlikely) or a chromedriver issue (much more likely), or possibly even an issue with Chrome. Since I do not see the issue on Mac OS, I suspect it is a Windows-specific chromedriver issue. You may want to tell the chromedriver folk that you can reproduce the issue in plain Selenium as well to help them troubleshoot.

bnx9908 commented 10 months ago

This might indicate that it is either a Selenium issue (very unlikely) or a chromedriver issue (much more likely), or possibly even an issue with Chrome. Since I do not see the issue on Mac OS, I suspect it is a Windows-specific chromedriver issue. You may want to tell the chromedriver folk that you can reproduce the issue in plain Selenium as well to help them troubleshoot.

Yep, I've added a comment regarding the plain Selenium repro. Thank you!

bnx9908 commented 9 months ago

Hello @wakaleo πŸ‘‹

Unfortunately, the ticket got closed with this comment 😞 : image

wakaleo commented 9 months ago

@bnx9908 - I don't really know what they mean. When a test finishes (no matter what the result) we call quit() on the chromedriver. There is nothing more we can do on the Serenity side to make the process exit, so I don't know what to do with this.

Maybe ask them if the process is supposed to exit when you call quit(), and if not how do the processes terminate? I still feel this is a chromedriver bug.

bnx9908 commented 9 months ago

@wakaleo I don't know where to ask this anymore, as they instantly closed the ticket with "WontFix" resolution and no more comments can be added 😞

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4672

wakaleo commented 9 months ago

There is nothing we can do in the Serenity code, as it already does the maximum it can (i.e. calls quit() for each driver. Since it is the Chrome browser that is being left open, and only for WIndows, the only possibly source is an error in the chromedriver or maybe a Chrome bug.

wakaleo commented 8 months ago

Closing as not related to Serenity.