无法运行 Appium 测试用例



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

我将我的演示.apk粘贴到应用程序目录中

我在我的Eclipse IDE中安装了TestNG插件

在运行我的 AppiumTest.java 之前,我通过运行 Appium 来启动 Appium 服务器.exe我得到的消息是

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->TestNG Test 运行我的 AppiumTest.java 我收到一条消息,JAVA_TOOL_OPTIONS:-Djava.vendor="Sun Microsystem Inc.",但我无法运行它。我怎样才能解决我的问题。任何人都可以就我的问题向我提出建议吗

在跑步时,我得到了,

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."
使用

AppiumDriver 代替 RemoteWebDriver,可以分别使用 IOSDriver 或 AndroidDriver

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

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

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

相关内容

  • 没有找到相关文章

最新更新