简体   繁体   English

Java命令未在Appium中执行

[英]Java commands is not executing in appium

I am using an appium application for the past week. 过去一周,我正在使用一个appium应用程序。 However, since the last two days it has not been working properly. 但是,自最近两天以来,它一直无法正常工作。 My Java program is not getting executed in appium application. 我的Java程序未在appium应用程序中执行。 It was also not displaying any error messages when I run scripts. 当我运行脚本时,它也没有显示任何错误消息。 When I run the program, there is also no error messages in the console and nothing is happening in appium application as well. 当我运行该程序时,控制台中也没有错误消息,并且在appium应用程序中也没有任何反应。

I am using windows 7 and latest version of Eclipse and appium tools. 我正在使用Windows 7和最新版本的Eclipse和Appium工具。

Code: 码:

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();
}
}

This is what I'm getting in the Eclipse console: 这是我在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

It always display these messages in eclipse console. 它总是在eclipse控制台中显示这些消息。 Why is this so and how do I fix it? 为什么会这样,我该如何解决?

You are using the JUnit @BeforeClass and @Test annotations. 您正在使用JUnit @BeforeClass和@Test批注。

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

And running the test through TestNG. 并通过TestNG运行测试。 Remove and add the wrong import statements. 删除并添加错误的导入语句。

Hope this will help. 希望这会有所帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM