Serenity BDD Maven Fails на GitLab CI -Timeout, NoSuchElementException, элемент не найден вместо этого на локальном компьютере работает - PullRequest
0 голосов
/ 29 января 2020

Если я запускаю тест maven serenity на локальной машине, все работает нормально . Вместо этого, когда я запускаю конвейер на GitLab CI, он не дает мне в консоли следующую ошибку:

TEST FAILED WITH ERROR: User Authentication
---------------------------------------------------------------------
14:31:46.500 [pool-1-thread-1] DEBUG n.t.c.steps.ConsoleLoggingListener - RELATED ISSUES: 
14:31:46.646 [pool-1-thread-1] ERROR n.t.c.steps.ConsoleLoggingListener - TEST FAILED AT STEP Perform authentication
14:31:46.646 [pool-1-thread-1] ERROR n.t.c.steps.ConsoleLoggingListener - Timed out after 50 seconds. Element not found
Feature: Authentication to the XXXXXXXX
  Scenario Outline: User Authentication # src/test/resources/features/authentication/authentication.feature:3
    Given the "<page>" page
    When I perform authentication as "<role>"
    Then I should be logged in
    Examples: 
  Scenario Outline: User Authentication # src/test/resources/features/authentication/authentication.feature:9
    Given the "login" page             # AuthenticationStepDefinitions.the_page(String)
    When I perform authentication         # AuthenticationStepDefinitions.i_perform_authentication()
      org.openqa.selenium.NoSuchElementException: Timed out after 50 seconds. Element not found
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'runner-4ZVpZRdnG-project-3-concurrent-0', ip: '172.21.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.1.3.el7.x86_64', java.version: '1.8.0_242'
Driver info: driver.version: unknown

Конфигурация, которую я использовал, очень проста:

это мой 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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>eu.inn.locara</groupId>
    <artifactId>myproject-acceptance-tests</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.version>2.0.69</serenity.version>
        <serenity.maven.version>2.0.69</serenity.maven.version>
        <serenity.cucumber.version>1.0.21</serenity.cucumber.version>
        <cucumber.version>4.2.0</cucumber.version>
        <encoding>UTF-8</encoding>
        <tags></tags>
        <parallel.tests>4</parallel.tests>
        <webdriver.driver>chrome</webdriver.driver>
    </properties>

    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.0.13</version>
        </dependency>
        <!-- - To use Cucumber 4, exclude the old Cucumber 2 cucumber-core dependency 
            from the serenity-core dependency - and include the Cucumber 4 cucumber-java 
            and cucumber-junit dependencies. -->
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>io.cucumber</groupId>
                    <artifactId>cucumber-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-cucumber4</artifactId>
            <version>${serenity.cucumber.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>eu.mycompany.myproject</groupId>
            <artifactId>myproject-model-dto</artifactId>
            <version>0.0.2-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <systemPropertyVariables>
                        <webdriver.driver>${webdriver.driver}</webdriver.driver>
                    </systemPropertyVariables>
                    <parallel>classes</parallel>
                    <threadCount>${parallel.tests}</threadCount>
                    <forkCount>${parallel.tests}</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.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.serenity-bdd.maven.plugins</groupId>
                <artifactId>serenity-maven-plugin</artifactId>
                <version>${serenity.maven.version}</version>
                <configuration>
                    <tags>${tags}</tags>
                </configuration>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

это мой .gitlab-ci.yml

image: maven:3.6.3-jdk-8

variables:
  MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
  MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"

  stages:
    - test

  test:
    stage: test
    allow_failure: true
    services:
        - name: selenium/standalone-chrome     
          alias: selenium
    script:
        - mvn verify

и, наконец, это мой serenity.conf :

webdriver {
  driver = chrome
  use.driver.service.pool = false
  remote.url="http://selenium:4444/wd/hub/"
  remote.driver=chrome
}
webdriver.timeouts.implicitlywait=50000

# If open browser or background
headless.mode = true

#
# Chrome options can be defined using the chrome.switches property
#
chrome.switches="""--window-size=1920,1080;--headless;--start-maximized;--test-type;--no-sandbox;--ignore-certificate-errors;
                   --disable-popup-blocking;--disable-default-apps;--disable-extensions-file-access-check;
                   --incognito;--disable-infobars,--disable-gpu"""

environments {
  default {
    # used
    webdriver.base.url = "http://gitlabrunner.mycompany.lan/#"
  }
  docker {
    # not used
    webdriver.base.url = "http://gitlabrunner.mycompany.lan/#"
  }
  dev {
    # not used
    webdriver.base.url = "https://www.google.it"
  }
  staging {
    # not used
    webdriver.base.url = "https://www.google.it"
  }
  prod {
    # not used
    webdriver.base.url = "https://www.google.it"
  }
}

Если я запускаю локально контейнер селен / автономный - chrome (см. Следующее изображение) запуск контейнера - селен / автономный - chrome

и я запускаю mvn verify в консоли моего локального компьютера (с заголовком true или false), все работает как положено!

Скажите, если я пропустил некоторую важную информацию, поэтому я могу добавить их. Эта проблема сводит меня с ума! Любое предложение приветствуется!

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...