我已经开始研究 Yandex Html Elements 框架。我按照入门指南https://github.com/yandex-qatools/htmlelements-examples/blob/master/htmlelements-junit-example/src/site/junit-example.md
并在一开始就停止
public class MainPage {
private WebDriver driver;
@FindBy(className = "b-morda-search-form")
private SearchArrow searchArrow;
public MainPage(final WebDriver driver) {
PageFactory.initElements(new HtmlElementDecorator(driver), this);
this.driver = driver;
}
public SearchPage searchFor(String request) {
this.searchArrow.searchFor(request);
return new SearchPage(driver);
}
}
线
PageFactory.initElements(new HtmlElementDecorator(driver), this);
创建错误
错误:(26, 59) java: 不兼容的类型:org.openqa.selenium.WebDriver 无法转换为 ru.yandex.qatools.htmlelements.pagefactory.CustomElementLocatorFactory
它只是这样工作:
PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this);
为什么?
我正在使用 IDEA 15 Ultimate,Java 8
pom文件:
<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>vasidizus</groupId>
<artifactId>Autotest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Autotest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.htmlelements</groupId>
<artifactId>htmlelements-java</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.htmlelements</groupId>
<artifactId>htmlelements-matchers</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.matchers</groupId>
<artifactId>webdriver-matchers</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.matchers</groupId>
<artifactId>common-matchers</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
</dependencies>
</project>
先谢谢了