ChromeDriver is assuming that Chrome has crashed in jenkins pipeline

I am using mvn test command to run selenium test cases using chrome and chrome driver with same versions on ubuntu 20.04. When I run mvn test command in terminal it works fine in the directory build was successful. When I run mvn test command in jenkins pipeline it gives me error.

> [ERROR] initialization(LogInCases)  Time elapsed: 2.525 s  <<<
> FAILURE! org.openqa.selenium.SessionNotCreatedException:  Could not
> start a new session. Response code 500. Message: unknown error: Chrome
> failed to start: crashed.   (unknown error: DevToolsActivePort file
> doesn't exist)   (The process started from chrome location
> /usr/bin/google-chrome is no longer running, so ChromeDriver is
> assuming that Chrome has crashed.)

My jenkins pipeline stage command is

sh 'cd home/useradmin/files/ && mvn test'

How to fix this so that I can get the same result in a machine terminal as in jenkins pipeline.

Hello @umairhameed236, and welcome to this community! :wave:

Is your Jenkins agent the same machine where you performed the tests using the command line?
If not, please test on the Jenkins agent machine using the command line.
On your local machine, do you have the webdriver.chrome.driver environment variable defined?

Yes Jenkins is running on the same machine where i am performing the task. Yes i have installed chrome driver but unable to set environment variable can you help me?

1 Like

What about

stage('Run Tests') {
    steps {
        sh '''
            export webdriver.chrome.driver=/path/to/chromedriver
            cd home/useradmin/files/
            mvn test
        '''
    }
}

?

Use this command still same error !

1 Like

At least I tried. :person_shrugging:
I’m sorry but don’t know more about this subject.

can you share me installing of chrome steps maybe i am doing it wrong

Is this issue got fixed?

I am getting same issue. @umairhameed236 @thiru were able to fix this?