2

过去一周我正在使用 appium 应用程序。但是,自最近两天以来,它一直无法正常工作。我的 Java 程序没有在 appium 应用程序中执行。当我运行脚本时,它也没有显示任何错误消息。当我运行程序时,控制台中也没有错误消息,appium 应用程序中也没有发生任何事情。

我正在使用 Windows 7 和最新版本的 Eclipse 和 appium 工具。

代码:

package sichernTest;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeMethod;

import io.appium.java_client.android.AndroidDriver;

public class SichernTestAuto {
    private WebDriver driver=null;

    @BeforeMethod
    @BeforeClass
    public void setUp() throws MalformedURLException{
        //Set up desired capabilities and pass the Android app-activity and app-package to Appium
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("automationName", "Appium");
        capabilities.setCapability("BROWSER_NAME", "Android");
        capabilities.setCapability("VERSION", "4.4.2"); 
        capabilities.setCapability("deviceName","Micromax");

       capabilities.setCapability("appPackage", "com.yelads.sichern.activity");
    // This package name of your app (you can get it from apk info app)
        capabilities.setCapability("appActivity","com.yelads.sichern.activity.Sichern"); // This is Launcher activity of your app (you can get it from apk info app)
    //Create RemoteWebDriver instance and connect to the Appium server
     //It will launch the Calculator App in Android Device using the configurations specified in Desired Capabilities
     driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

    }


    @Test
    public void testCal() throws Exception {
WebElement signUp=driver.findElement(By.id("com.yelads.sichern.activity:id/signup_button"));
        signUp.click();
        driver.findElement(By.id("com.yelads.sichern.activity:id/email")).sendKeys("user@mail.com");
        driver.findElement(By.id("com.yelads.sichern.activity:id/confirm_email")).sendKeys("user@mail.com");
        driver.findElement(By.id("com.yelads.sichern.activity:id/msisdn")).sendKeys("9008515957");
        driver.findElement(By.id("com.yelads.sichern.activity:id/first_name")).sendKeys("Bharath L");
        driver.hideKeyboard();
}
}

这就是我在 Eclipse 控制台中得到的:

[TestNG] Running:
  C:\Users\bharat\AppData\Local\Temp\testng-eclipse-1900899765\testng-customsuite.xml


===============================================
    Default test
    Tests run: 0, Failures: 0, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 0, Failures: 0, Skips: 0
===============================================

[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@36300ca7: 29 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@102e6640: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@48801b62: 87 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@37b335b7: 0 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@3bc51342: 15 ms

它总是在 Eclipse 控制台中显示这些消息。为什么会这样,我该如何解决?

4

1 回答 1

0

您正在使用 JUnit @BeforeClass 和 @Test 注释。

import org.junit.BeforeClass;
import org.junit.Test;

并通过 TestNG 运行测试。删除并添加错误的导入语句。

希望这会有所帮助。:)

于 2015-11-25T11:33:11.667 回答