junit测试在jenkins构建中失败

时间:2018-09-21 09:53:00

标签: java jenkins appium appium-android

需要帮助

所以我想让我的自动化在詹金斯工作中运行。有关信息,我使用appium studio。所以现在我的测试可以在appium studio和eclipse上运行。但是在jenkins上运行build时,出现以下错误

enter image description here

我的设置 enter image description here

build.xml enter image description here

测试结果: test result

代码:

package junit;
//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.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
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 junit {
private String reportDirectory = "reports";
private String reportFormat = "xml";
private String testName = "tiket1adult";
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");
    dc.setCapability("instrumentApp", true);
    driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), dc);
    driver.setLogLevel(Level.INFO);
}
 @Test
public void testtiket1adult() {
    driver.findElement(By.xpath("//*[@id='it_next' and (./preceding-sibling::* | ./following-sibling::*)[./*[@text='Tiket Pesawat']]]")).click();
    new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@text='CARI TIKET' and @width>0]")));
    driver.findElement(By.xpath("//*[@text='CARI TIKET' and @width>0]")).click();
    driver.findElement(By.xpath("//*[@text='per orang' and ./parent::*[./parent::*[(./preceding-sibling::* | ./following-sibling::*)]]]")).click();
    driver.findElement(By.xpath("//*[@text='Pesan']")).click();
}
 @After
public void tearDown() {
    driver.quit();
}

}

0 个答案:

没有答案