ElementNotVisibleException в JBehave - PullRequest
       64

ElementNotVisibleException в JBehave

0 голосов
/ 15 октября 2018

Я сталкиваюсь с этой проблемой с выпадающими.

Ошибки начались с SerenityManagedException, но я продолжал улучшаться и, наконец, застрял в этом.

Я уже пробовал обновить версию Serenity, плагин Jbehave в pom.xml (прилагается) и двоичные версии Chrome до последней версии 2.42.0.Он может найти поля ввода совершенно нормально, но не может найти раскрывающийся список.Я упоминал HTML для обоих

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>com.demo.automation</groupId>
    <artifactId>demo-automation-tests</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Sample Serenity project using JBehave and WebDriver</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.version>2.0.7</serenity.version>
        <serenity.jbehave.version>1.42.0</serenity.jbehave.version>
        <webdriver.driver>firefox</webdriver.driver>
    </properties>

    <repositories>
      <repository>
        <snapshots>
        <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray</name>
        <url>http://jcenter.bintray.com</url>
      </repository>
    </repositories>
    <pluginRepositories>
      <pluginRepository>
        <snapshots>
        <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray-plugins</name>
        <url>http://jcenter.bintray.com</url>
      </pluginRepository>
    </pluginRepositories>

    <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-jbehave</artifactId>
            <version>${serenity.jbehave.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </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.19.1</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*TestSuite.java</include>
                        <include>**/Test*.java</include>
                        <include>**/When*.java</include>
                    </includes>
                    <argLine>-Xmx512m</argLine>
                    <systemPropertyVariables>
                        <webdriver.driver>${webdriver.driver}</webdriver.driver>
                    </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>3.2</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.version}</version>
                <executions>
                    <execution>
                        <id>serenity-reports</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

HTML для поля ввода, которое проходит:

<input class="form_field form_field_text" 
id="_content_wynn_en_US_index_forms_tbd-approval-cost- 
problems_FirstName" name="FirstName" value="" size="35" onkeydown="" 
placeholder="First Name*" aria-required="true" style="border-bottom: 
1px solid rgb(255, 0, 0);" aria-invalid="true">
@FindBy(xpath="//input[contains(@name,'FirstName') and @aria-required='true']")
private WebElementFacade first_name;

HTML для поля выбора, в котором отсутствует:

<div class="form_rightcol">
    <select class="form_field form_field_select jcf-hidden" 
        id="_content_wynn_en_US_index_forms_apm-solves-common-problems_JobLevel" 
        name="JobLevel" aria-required="true">
        <option value="">Job Level*</option>
        <option value="C-Level">C-Level</option>
        <option value="Senior Vice President/Vice President">Senior Vice President/Vice President</option>
        <option value="Senior Director/Director">Senior Director/Director</option>
        <option value="Manager/Team Lead">Manager/Team Lead</option>
        <option value="Individual Contributor">Individual Contributor</option>
        <option value="Partner">Partner</option><option value="Student">Student</option>
        <option value="Other">Other</option>
    </select>
    <span class="jcf-select jcf-unselectable jcf-select-form_field jcf-select-form_field_select" style="border-bottom: 1px solid rgb(255, 0, 0);">
        <span class="jcf-select-text">
            <span class="">Job Level*</span>
        </span>
        <span class="jcf-select-opener"></span>
    </span>
</div>`
@FindBy(xpath="//select[contains(@name,'JobLevel') and @aria-required='true']")
private WebElementFacade job_level;

Ошибка:

org.openqa.selenium.ElementNotVisibleException
com.demo.automation.pages.DemoPage.assert_missing_fields(DemoPage.java:114)
com.demo.automation.steps.serenity.EndUserSteps.assert_missing_fields(EndUserSteps.java:25)
com.demo.automation.steps.DemoValidationSteps.getAlertOnTheDemoMissingField(DemoValidationSteps.java:31)
...