Я новичок в автоматизации. Я использую Java11, Maven 3.6.2, Selenium 4.0.0-alpha-3, TestNG 7.0.0. Моя проблема в том, что я пытаюсь реализовать свободное ожидание в моих методах, но я получаю ошибку:
до (java.util.function.Functionorg.openqa.selenium.WebDriver, java.lang.Object>) в FluentWait не может применяться к (org.openqa.selenium.support.ui.ExpectedCondition)
Я пробовал разные подходы: импортировал статические ExpectedConditions, добавил Guava в зависимостях, но ничего не работает.
Мой файл с родителями:
<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.name</groupId>
<artifactId>xyz-parent</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>ism-parent</name>
<modules>
<module>xyz-functional-tests</module>
</modules>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<!-- Test user credentials -->
<username>test.user</username>
<password>pass</password>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.11</java.version>
<maven.compiler.release>11</maven.compiler.release>
<!-- Version Management -->
<testng.version>7.0.0</testng.version>
<webdriver-factory.version>4.3</webdriver-factory.version>
<selenium-java.version>4.0.0-alpha-3</selenium-java.version>
<guava.version>28.1-jre</guava.version>
<google-api-client.version>1.30.5</google-api-client.version>
<allure.version>2.13.0</allure.version>
<assertj.version>3.14.0</assertj.version>
<assertj-joda-time.version>2.2.0</assertj-joda-time.version>
<lombok.version>1.18.10</lombok.version>
<logback-classic.version>1.3.0-alpha4</logback-classic.version>
<slf4j-api.version>2.0.0-alpha1</slf4j-api.version>
<jackson-annotations.version>2.10.0</jackson-annotations.version>
<jackson-databind.version>2.10.0</jackson-databind.version>
<snake-case.version>2.1.0</snake-case.version>
<snakeyaml.version>1.25</snakeyaml.version>
<commons-lang3.version>3.9</commons-lang3.version>
<log4j.version>1.2.17</log4j.version>
<javax.json-api.version>1.1.4</javax.json-api.version>
<json.version>20190722</json.version>
<surefire.version>3.0.0-M3</surefire.version>
<surefire-testng.version>3.0.0-M3</surefire-testng.version>
<versions-maven-plugin.version>2.7</versions-maven-plugin.version>
<aspectj.version>1.9.4</aspectj.version>
<awaitility.version>4.0.1</awaitility.version>
<joda-time.version>2.10.5</joda-time.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium-java.version}</version>
</dependency>
<!-- Allure Report -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.version}</version>
</dependency>
<!-- Jackson annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-annotations.version}</version>
</dependency>
<!-- Jackson Databind-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!-- Surefire testng -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${surefire-testng.version}</version>
</dependency>
<!-- WebDriver Factory-->
<dependency>
<groupId>ru.stqa.selenium</groupId>
<artifactId>webdriver-factory</artifactId>
<version>${webdriver-factory.version}</version>
</dependency>
<!-- Snake YAML -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<!-- Apache Commons Lang -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- Logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- json API -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>${javax.json-api.version}</version>
</dependency>
<!-- json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>${json.version}</version>
</dependency>
<!-- AssertJ -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
<!-- AssertJ Joda Time-->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-joda-time</artifactId>
<version>${assertj-joda-time.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>${awaitility.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<!-- Allure Report -->
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>2.8</version>
<configuration>
<propertiesFilePath>resources/allure.properties</propertiesFilePath>
</configuration>
</plugin>
<!-- Surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
<!-- Resources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<executable>${JAVA_HOME}/bin/javac</executable>
</configuration>
</plugin>
<!-- Enforcer -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.2</version>
<message>Invalid Maven version. It should, at least, be 3.6.2</message>
</requireMavenVersion>
<requireJavaVersion>
<version>1.11</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Exec maven -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${JAVA_HOME}/bin/javac</executable>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<!-- Browsers -->
<profile>
<id>firefox</id>
<properties>
<capabilities>/firefox.capabilities</capabilities>
<browser>Firefox</browser>
</properties>
</profile>
<profile>
<id>chrome</id>
<properties>
<capabilities>/chrome.capabilities</capabilities>
<browser>Chrome</browser>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- Environments -->
<profile>
<id>UAT</id>
<properties>
<site.url>http://XYZ:</site.url>
</properties>
</profile>
<!-- Selenium Grid -->
<profile>
<id>local</id>
<properties>
<grid.url/>
<grid.files.url/>
<env>local</env>
</properties>
</profile>
<profile>
<id>grid</id>
<properties>
<grid.url>http:XYZ/wd/hub/</grid.url>
<grid.files.url>http:/XYZ</grid.files.url>
<env>grid</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>skipDuplicateTestNames</id>
<properties>
<skip.duplicate.test.names>true</skip.duplicate.test.names>
</properties>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
</profile>
</profiles>
</project>
Ребенок:
<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>
<parent>
<groupId>com.name</groupId>
<artifactId>xyz-parent</artifactId>
<version>1</version>
</parent>
<artifactId>xyz-functional-tests</artifactId>
<name>xyz-functional-tests</name>
<version>1</version>
<packaging>jar</packaging>
<properties>
<threadCount>5</threadCount>
<parallelStrategy>tests</parallelStrategy>
<suiteFile>testng.xml</suiteFile>
</properties>
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>${basedir}src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>${parallelStrategy}</parallel>
<threadCount>${threadCount}</threadCount>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<systemPropertyVariables>
<application.properties>/application.properties</application.properties>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/${suiteFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-allure-environment</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/allure-results</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>environment.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<!-- Allure Report -->
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
</dependency>
<!-- Jackson annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<!-- Jackson Databind-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- Surefire testng -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
</dependency>
<!-- WebDriver Factory-->
<dependency>
<groupId>ru.stqa.selenium</groupId>
<artifactId>webdriver-factory</artifactId>
</dependency>
<!-- Snake YAML -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<!-- Apache Commons Lang -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- Logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<!-- json API -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
</dependency>
<!-- json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<!-- AssertJ -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<!-- AssertJ Joda Time-->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-joda-time</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
</dependency>
</dependencies>
</project>
Класс с wait.until:
package com.ion.web;
import com.xyz.web.common.NavigationBar;
import io.qameta.allure.Step;
import lombok.extern.slf4j.Slf4j;
import org.awaitility.core.ConditionTimeoutException;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.pagefactory.ElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static java.lang.String.format;
import static org.awaitility.Awaitility.await;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
@Slf4j
public abstract class WebPage {
protected final WebDriver driver;
protected final Actions actions;
protected final WebDriverWait wait;
@FindBy(id = "t_TreeNav")
private WebElement navigationBar;
@FindBy(xpath = "/html/head/title")
protected WebElement pageTitle;
public WebPage(final WebDriver driver, WebDriverWait wait) {
this.driver=driver;
this.wait = wait;
initElements();
actions = new Actions(driver);
handleOnBeforeUnload();
}
public void refreshPage() {
log.debug("Refreshing the page.");
driver.navigate().refresh();
handleOnBeforeUnload();
}
@Step
public NavigationBar getNavigationBar() {
wait.until(ExpectedConditions.visibilityOf(navigationBar));
return new NavigationBar(driver, navigationBar);
}
Буду благодарен за любые советы.