Search code examples
githubselenium-webdriverenvironment-variablesgithub-actionscicd

org.openqa.selenium.SessionNotCreatedException: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist)


Im facing an error while executing my pom.xml in build job of github actions workflow,

Below is my yml file:

name: Selenium Tests

on:
  workflow_dispatch:
  push:
    branches:
      - main
      - feature/Aditya-Singh
  pull_request:
    branches:
      - main
      - feature/Aditya-Singh`

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 11
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'adopt'  
      - name: Set up Chrome browser
        uses: browser-actions/setup-chrome@v1
        with:
          options: |
            --disable-dev-shm-usage
            --ignore-ssl-errors=yes
            --ignore-certificate-errors
            --no-sandbox
            --headless
      - run: google-chrome-stable --version
      - name: Set variable value
        run: echo "PRODUCT_ID=B09RX285W1" >> $GITHUB_ENV
      - name: Build with Maven and run Selenium tests
        run: mvn -f Amazon\ Product/pom.xml clean test -DPRODUCT_ID="${{ env.PRODUCT_ID }}"

The error occurs in step named as Build with Maven and run Selenium Test in yml file

Below is my pom.xml file:

<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>Aditya</groupId>
    <artifactId>Assignment3</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.6.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.6.0</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.6.0</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>7.6.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.18.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.18.0</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>7.6.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>5.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>5.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>5.0.9</version>
        </dependency>
        <dependency>
            <groupId>tech.grasshopper</groupId>
            <artifactId>extentreports-cucumber7-adapter</artifactId>
            <version>1.7.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

I tried many workaround like adding following arguments in yml file for Chrome:

options: |
            --disable-dev-shm-usage
            --ignore-ssl-errors=yes
            --ignore-certificate-errors
            --no-sandbox
            --headless

But was of no avail. Can anyone help me out in this?


Solution

  • Only thing needed was to change from Chrome to Chrome headless in data.prop file