Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature X fails when i execute my yaml #3302

Open
SorayaAzzaoui opened this issue Oct 24, 2023 · 1 comment
Open

Feature X fails when i execute my yaml #3302

SorayaAzzaoui opened this issue Oct 24, 2023 · 1 comment

Comments

@SorayaAzzaoui
Copy link

What happened?

Hello everyone I have a problem with my project, the tests are not running I have a buid failure error, locally it works who could help me please thank you

What did you expect to happen?

4.0.0 com.Gex SerenityBDDFramworkSoraya 0.0.1-SNAPSHOT
<properties>
	<serenity.version>3.6.21</serenity.version>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<encoding>UTF-8</encoding>
</properties>



<dependencies>

	<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-simple</artifactId>
		<version>1.7.30</version>
		<scope>test</scope>
	</dependency>

	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-core</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	
			<dependency>
    <groupId>com.squareup.okhttp3</groupId>
    <artifactId>okhttp</artifactId>
    <version>4.9.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
org.seleniumhq.selenium selenium-java 4.8.1 net.serenity-bdd serenity-junit ${serenity.version} test
	<!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-cucumber -->
net.serenity-bdd serenity-cucumber ${serenity.version} test
	<!-- POI JARS STARTS -->

	<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi</artifactId>
		<version>4.1.1</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi-ooxml</artifactId>
		<version>4.1.1</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
	<dependency>
		<groupId>dom4j</groupId>
		<artifactId>dom4j</artifactId>
		<version>1.6.1</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
	<dependency>
		<groupId>org.apache.xmlbeans</groupId>
		<artifactId>xmlbeans</artifactId>
		<version>3.1.0</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
	<dependency>
		<groupId>org.apache.poi</groupId>
		<artifactId>poi-ooxml-schemas</artifactId>
		<version>4.1.1</version>
	</dependency>

	<!-- POI JARS ENDS -->
io.github.bonigarcia webdrivermanager LATEST org.seleniumhq.selenium selenium-http-jdk-client 4.8.1
</dependencies>



<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>3.0.0-M5</version>
			<configuration>
				 <systemPropertyVariables>
                <XRAY_TEST_PLAN_KEY>${XRAY_TEST_PLAN_KEY}</XRAY_TEST_PLAN_KEY>
            </systemPropertyVariables>
				<skip>true</skip>
			</configuration>
		</plugin>
		<plugin>
			<artifactId>maven-failsafe-plugin</artifactId>
			<version>3.0.0-M5</version>
			<configuration>
				<includes>
					<include>**/runners/*.java</include>
				</includes>

				<parallel>classes</parallel>
				<threadCount>2</threadCount>
				<forkCount>2C</forkCount>
			</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>3.7.0</version>
			<configuration>
				<source>17</source>
				<target>17</target>
			</configuration>
		</plugin>
		<plugin>
			<groupId>net.serenity-bdd.maven.plugins</groupId>
			<artifactId>serenity-maven-plugin</artifactId>
			<version>3.6.21</version>
			<executions>
				<execution>
					<id>serenity-reports</id>
					<phase>post-integration-test</phase>
					<goals>
						<goal>aggregate</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

package com.PageObject;

import io.github.bonigarcia.wdm.WebDriverManager;
import net.serenitybdd.core.pages.PageObject;

import java.time.Duration;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class LoginPage extends PageObject{

private WebDriver driver;

public LoginPage(WebDriver driver) {
    this.driver = driver;
}

public void openGex() {
    WebDriverManager.chromedriver().setup();

    // Manually navigate to the URL
    String url = "https://env11-pre.ivalua.app/buyer/oxylane/prepevol17/j86f4/page.aspx/fr/buy/homepage/cpt";
    driver.get(url);

    // Maximize the window
    driver.manage().window().maximize();

    // Fill in the login form
    WebElement usernameField = driver.findElement(By.id("username"));
    WebElement passwordField = driver.findElement(By.id("password"));
    WebElement loginButton = driver.findElement(By.id("cnxbton"));

    usernameField.click();
    usernameField.sendKeys("XXXXXXXXX");

    passwordField.click();
    passwordField.sendKeys("XXXXXXX");

    loginButton.click();

    // Click on the user profile dropdown
    WebElement userProfileDropdown = driver.findElement(By.cssSelector("button[id='header_x_prxHeaderLogInfo_x_btnLoginMenu'] i[class='fa-caret-down solid right icon']"));
    userProfileDropdown.click();

    // Select the English language
    WebElement languageDropdown = driver.findElement(By.xpath("//select[@id='ddlLang']"));
    languageDropdown.click();

    WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
    WebElement changeProfileToEnglish = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("option[value='en']")));
    changeProfileToEnglish.click();
}

}

Serenity BDD version

3.6.21

JDK version

17

Execution environment

package com.gex.runners;

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.core.Serenity;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;

@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
plugin = {"pretty", "json:target/cucumber-reports/Cucumber.json"},
features = {"src/test/resources/features"},
glue = {"com.gex.steps"}

)
public class TestRunner {
String testPlanKey = Serenity.sessionVariableCalled("xray.testplan.key");
}

How to reproduce the bug.

name: Testing

on:
workflow_dispatch:
inputs:
test_plan_key_variable:
description: 'Test Plan Key Variable'
default: 'AZ-' # You can set a default value here
required: true

jobs:
test:
timeout-minutes: 180
runs-on: ubuntu-20.04
steps:
- name: Debug Secrets
run: |
echo "CLIENT_ID: ${{ secrets.CLIENT_ID }}"
echo "CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}"
- name: Set inputs from workflow_dispatch
if: github.event_name == 'workflow_dispatch'
run: |
PLAN_TEST="${{ github.event.inputs.test_plan_key_variable }}"
echo "PLAN_TEST=$PLAN_TEST" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
with:
ref: main
fetch-depth: 0

  - name: JAVA JDK 17
    uses: actions/setup-java@v2
    with:
      java-version: '17'
      distribution: 'adopt'
      overwrite-settings: false 
 
  - name: Cache Maven packages
    uses: actions/cache@v2
    with:
      path: ~/.m2
      key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
      restore-keys: ${{ runner.os }}-m2

  - name: Install Chrome
    uses: browser-actions/setup-chrome@v1
  

      
  - name: Install unzip
    run: |
      sudo apt-get install unzip
    if: success() # Install unzip only if previous steps are successful

  - name: Get xray cloud API token
    run: |
      token=$(curl -H "Content-Type: application/json" -X POST --data '{ "client_id": "${{ secrets.XRAY_CLIENT_ID }}", "client_secret": "${{ secrets.XRAY_CLIENT_SECRET }}" }' https://xray.cloud.getxray.app/api/v2/authenticate | tr -d '"')
      echo "XRAY_TOKEN=$token" >> $GITHUB_ENV
      echo $token
    env:
      XRAY_CLIENT_ID: ${{ secrets.XRAY_CLIENT_ID }}
      XRAY_CLIENT_SECRET: ${{ secrets.XRAY_CLIENT_SECRET }}
      
  

  
      
  - name: Create features directory
    run: mkdir -p $GITHUB_WORKSPACE/my-temp-directory/features


  - name: Export scenarios from Xray and generate .feature file(s)
    run: |
      curl -X GET -L -H "Content-Type: application/json" -o $GITHUB_WORKSPACE/my-temp-directory/features.zip -X GET -H "Authorization: Bearer $token" "https://xray.cloud.getxray.app/api/v1/export/cucumber?keys=${{ github.event.inputs.test_plan_key_variable }}"
  - name: Check features.zip file size
    run: |
      ls -l $GITHUB_WORKSPACE/my-temp-directory/features.zip
    continue-on-error: true

  - name: Re-download features.zip
    run: |
      curl -X GET -L -H "Content-Type: application/json" -o $GITHUB_WORKSPACE/my-temp-directory/features.zip -H "Authorization: Bearer $XRAY_TOKEN" "https://xray.cloud.getxray.app/api/v1/export/cucumber?keys=${{ github.event.inputs.test_plan_key_variable }}"
  - name: Examine the contents of *.zip
    run: |
      ZIP_FILE=$(find $GITHUB_WORKSPACE/my-temp-directory -name "*.zip" -type f)
      
      if [ -n "$ZIP_FILE" ]; then
        unzip -l $ZIP_FILE
        unzip -q -o $ZIP_FILE -d $GITHUB_WORKSPACE/my-temp-directory/features
        ls -R $GITHUB_WORKSPACE/my-temp-directory/features
      else
        echo "Aucun fichier zip trouvé."
      fi
    continue-on-error: true # Continue even if there's an error

          
         
  - name: Examine and unzip the contents of *.zip
    run: |
      for zip_file in $GITHUB_WORKSPACE/my-temp-directory/*.zip; do
        if [ -e "$zip_file" ]; then
          unzip -o -q "$zip_file" -d $GITHUB_WORKSPACE/my-temp-directory/features
        fi
      done
    continue-on-error: true # Continue même s'il y a une erreur


  - name: Afficher le contenu des fichiers extraits
    run: |
      for file in $GITHUB_WORKSPACE/my-temp-directory/features/*; do
        if [ -f "$file" ]; then
          cat "$file"
        fi
      done
    continue-on-error: true

  - name: Créer le fichier test.feature
    run: touch $GITHUB_WORKSPACE/src/test/resources/features/test.feature

  - name: Copier le fichier .feature
    run: |
      # Rechercher un fichier avec l'extension .feature dans le répertoire source
      feature_file=$(find $GITHUB_WORKSPACE/my-temp-directory/features -type f -name "*.feature")
    
      # Vérifier si un fichier .feature a été trouvé
      if [ -n "$feature_file" ]; then
        # Copier le fichier .feature dans le répertoire de destination en le renommant en test.feature
        cp "$feature_file" $GITHUB_WORKSPACE/src/test/resources/features/test.feature
      else
        echo "Aucun fichier .feature trouvé dans le répertoire source."
      fi
  

  
  - name: Exécuter les tests Maven du fichier test.feature
    run: mvn clean verify -Dcucumber.features=$GITHUB_WORKSPACE/src/test/resources/features/test.feature -f $GITHUB_WORKSPACE/pom.xml || true

    
      

  - name: Archive Serenity Reports
    uses: actions/upload-artifact@v2
    with:
        name: serenity-reports
        path: target/serenity-reports

  - name: Set Serenity Reports URL
    id: set-reports-url
    run: |
      ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
      echo "::set-output name=url::$ARTIFACT_URL"
  - name: Send email with Serenity report link
    run: |
      ARTIFACT_URL="${{ steps.set-reports-url.outputs.url }}"
      echo "Hi,
      Please find the Serenity test reports at the following link:
      [Open Serenity Reports]($ARTIFACT_URL)
      Best regards,
      Your CI Workflow" | mail -s "Serenity Test Reports" sorayaaikar@hotmail.com
  - name: Checkout gh-pages branch
    uses: actions/checkout@v2
    with:
      ref: gh-pages
      path: gh-pages

  - name: Upload Serenity reports zip to GitHub Pages
    uses: peaceiris/actions-gh-pages@v3
    with:
      github_token: ${{ secrets.GITHUB_TOKEN }}
      publish_dir: gh-pages
      publish_branch: gh-pages
      keep_files: true

  - name: Get Serenity Reports URL
    id: get-reports-url
    run: |
      ARTIFACT_URL="https://github.com/${{ github.repository }}/tree/gh-pages"
      echo "::set-output name=url::$ARTIFACT_URL"
  - name: Send email with Serenity report link
    run: |
      ARTIFACT_URL="${{ steps.get-reports-url.outputs.url }}"
      echo "Hi,
      Please find the Serenity test reports at the following link:
      [Open Serenity Reports]($ARTIFACT_URL)
      Best regards,
      Your CI Workflow" | mail -s "Serenity Test Reports" soraya.azzaoui.partner@decathlon.com
  - name: Submit results to Xray
    if: always()
    uses: mikepenz/xray-action@v2.4.5
    with:
      username: ${{ secrets.XRAY_CLIENT_ID }}
      password: ${{ secrets.XRAY_CLIENT_SECRET }}
      xrayCloud: true
      testFormat: "junit"
      testPaths: "/home/runner/work/GexSerenityBDDFramwork/GexSerenityBDDFramwork/target/failsafe-reports/TEST-*.xml"
      projectKey: "AZ"
      testExecKey: ${{ github.event.inputs.test_exec_key_variable }}
      testPlanKey: ${{ github.event.inputs.test_plan_key_variable }}

  
  - name: Remove the temporary directory
    run: |
      rm -rf $GITHUB_WORKSPACE/my-temp-directory
      
      
      BUILD ERROR:

Downloaded from central: https://repo.maven.apache.org/maven2/org/bouncycastle/bcprov-jdk15on/1.64/bcprov-jdk15on-1.64.jar (4.8 MB at 15 MB/s)
[INFO] Test results for 2 tests generated in 2.3 secs in directory: file:/home/runner/work/GexSerenityBDDFramwork/GexSerenityBDDFramwork/target/site/serenity/
[INFO] ------------------------------------------------
[INFO] | SERENITY TESTS: | ERROR
[INFO] ------------------------------------------------
[INFO] | Test scenarios executed | 2
[INFO] | Total Test cases executed | 2
[INFO] | Tests passed | 0
[INFO] | Tests failed | 0
[INFO] | Tests with errors | 2
[INFO] | Tests compromised | 0
[INFO] | Tests aborted | 0
[INFO] | Tests pending | 0
[INFO] | Tests ignored/skipped | 0
[INFO] ------------------------------- | --------------
[INFO] | Total Duration| 10s 123ms
[INFO] | Fastest test took| 550ms
[INFO] | Slowest test took| 9s 573ms
[INFO] ------------------------------------------------
[INFO]
[INFO] SERENITY REPORTS
[INFO] - Full Report: file:///home/runner/work/GexSerenityBDDFramwork/GexSerenityBDDFramwork/target/site/serenity/index.html
[INFO]
[INFO] --- maven-failsafe-plugin:3.0.0-M5:verify (default) @ SerenityBDDFramworkSoraya ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.386 s
[INFO] Finished at: 2023-10-24T11:08:28Z
[INFO] ------------------------------------------------------------------------
Error: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:3.0.0-M5:verify (default) on project SerenityBDDFramworkSoraya: There are test failures.
Error:
Error: Please refer to /home/runner/work/GexSerenityBDDFramwork/GexSerenityBDDFramwork/target/failsafe-reports for the individual test results.
Error: Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
Error: -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

How can we make it happen?

Work on this myself and propose a PR (with Serenity BDD team guidance)

@SorayaAzzaoui
Copy link
Author

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: WebDriver was unable to create a new instance of type class org.openqa.selenium.chrome.ChromeDriver
WebDriver reported the following message: Could not start a new session. Response code 500. Message: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant