无法运行Appium TestCase

时间:2015-03-13 05:20:11

标签: android appium testcase

AppiumTest.java

package com.test;

import java.io.File;
import java.net.URL;
import java.util.List;

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

public class AppiumTest {

    private WebDriver driver;

    @BeforeMethod
    public void setUp() throws Exception{
        File rootFile = new File(System.getProperty("user.dir"));
        File appFile = new File(rootFile, "Application");
        File app = new File(appFile, "demo.apk");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("device", "Android");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("app-package", "my_demo_apk_pck");
        capabilities.setCapability("app-activity", ".Login");
        driver = new RemoteWebDriver(new URL("http://0.0.0.0.4723/wd/hub"), capabilities);

    }

    @Test
    public void loginTest(){

        List<WebElement> txt = driver.findElements(By.className("android.widget.EditText"));
    }

我将 demo.apk 粘贴到应用目录

我在Eclipse IDE中安装了 TestNG 插件

在运行我的AppiumTest.java之前,我通过运行Appium.exe来启动Appium Server,然后我收到了消息

Starting Node Server
> info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
> info: Appium REST http interface listener started on 0.0.0.0:4723
> info: [debug] Non-default server args: {"app":"**\\demo.apk","logNoColors":true,"deviceName":"**","platformName":"Android","platformVersion":"18","automationName":"Appium"}
> info: Console LogLevel: debug

启动Appium服务器之后,我通过 RunAs-&gt; TestNG测试运行我的AppiumTest.java,并收到一条消息拾起JAVA_TOOL_OPTIONS:-Djava.vendor =&#34; Sun Microsystem Inc.&#34; ,我无法运行它。我怎样才能解决我的问题。任何人都可以向我提出我的问题

我跑步的时候,

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

[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@626b2d4a: 0 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@73a8dfcc: 29 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@6f2b958e: 3 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@aec6354: 25 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@c2e1f26: 3 ms
Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="Sun Microsystem Inc."

2 个答案:

答案 0 :(得分:0)

使用AppiumDriver而不是RemoteWebDriver,您可以分别使用IOSDriver或AndroidDriver

AppiumDriver驱动程序=新的IOSDriver(新网址(&#34; http://0.0.0.0.4723/wd/hub&#34;),功能)

答案 1 :(得分:0)

我一直在使用testng和eclipse很长时间但从未遇到过这个问题。尝试更改您的驱动程序,如下所示:

protected AppiumDriver driver;
driver = new AppiumDriver(new URL("http://0.0.0.0.4723/wd/hub"), capabilities);