我的第一目錄的樣子:的webdriver - 頁面對象模型和Maven找不到類
+- pom.xml
+- src/
+- test/
+- java/
+- dms.config/
+- config.java
+- dms.util/
+- generatedata.java
+- dms.pages/
+- LoginPage.java
+- dms.testcase/
+- LoginTest.java
我testng.xml
樣子:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
<test name="Test">
<classes>
<class name="dms.testcase.LoginTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
我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>pl.rsoftstudio</groupId>
<artifactId>dms</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dms</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
當我嘗試通過Maven運行我的測試我有:
[TestNGClassFinder]警告:無法鏈接,並確定類的方法dms.testcase.LoginTest
當我運行我的測試「運行方式」,「TestNG的測試」是確定。
我用右鍵單擊該項目,選擇的Maven>更新項目...
添加LoginTest.class:
package dms.testcase;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import dms.config.Main;
import dms.pages.kancelaria.LoginPage;
public class LoginTest extends Main {
LoginPage lp = new LoginPage();
@Test
public void login() throws Exception {
lp.login();
lp.password();
lp.buttonOK();
}
}
加油,停止猜測和說無意義。 ' SRC testSourceDirectory>'?真?它是'src/test/java',默認和OP使用它。 –
Tunaki
這是我如何使用maven運行我的測試 –