Java命令没有在appium

时间:2015-08-28 10:40:24

标签: java appium eclipse-mars

过去一周我使用的是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控制台中显示这些消息。为什么会这样,我该如何解决?

1 个答案:

答案 0 :(得分:0)

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

public bool fileInDb(int empId)
    {
        using (SLADbContext db = new SLADbContext())
        {
            bool file = db.CompetenceUploads.Any(x => x.EmployeeId == empId);
            if (file)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }  

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

希望这会有所帮助。 :)