我尝试使用 maven 项目运行我的测试用例,我也想与 jenkins 集成。但是 maven 没有运行我的 test.i 已经添加了对 appium 的依赖。但仍然没有运行测试。我使用 appium studio 制作我的测试用例并使用基于 junit 的复制代码...................................... ......
这是我使用java的代码:
package appium;
//package <set your test package>;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.junit.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.logging.Level;
public class appiumtest {
private String reportDirectory = "reports";
private String reportFormat = "xml";
private String testName = "login";
protected AndroidDriver<AndroidElement> driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
@Before
public void setUp() throws MalformedURLException {
dc.setCapability("reportDirectory", reportDirectory);
dc.setCapability("reportFormat", reportFormat);
dc.setCapability("testName", testName);
dc.setCapability(MobileCapabilityType.UDID, "f5a19fd4");
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.pegipegi.android");
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".main.activities.SplashActivity");
driver = new AndroidDriver<AndroidElement>(new URL("http://localhost:4723/wd/hub"), dc);
driver.setLogLevel(Level.INFO);
}
@Test
public void testlogin() {
driver.findElement(By.xpath("//*[@contentDescription='Open navigation drawer']")).click();
driver.findElement(By.xpath("//*[@text='Login / Register']")).click();
driver.findElement(By.xpath("//*[@id='edit_text_email']")).sendKeys("banditpepe1@gmail.com");
driver.findElement(By.xpath("//*[@id='edit_text_password']")).sendKeys("test12");
driver.findElement(By.xpath("//*[@text='LOGIN']")).click();
}
@After
public void tearDown() {
driver.quit();
}
}
她我的 pom.xml
<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>appi</groupId>
<artifactId>appium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<id>Experitest.repo1</id>
<name>YourName</name>
<url>http://repo.experitest.com:8010/Maven2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.experitest</groupId>
<artifactId>seetest-client</artifactId>
<version>11.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<includes>
<include>appiumtest.java</include>
</includes>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
构建日志:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< appi:appium >-----------------------------
[INFO] Building appium 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ appium ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ appium ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ appium ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ appium ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ appium ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.993 s
[INFO] Finished at: 2018-09-26T10:43:20+07:00
[INFO] ------------------------------------------------------------------------