我正在尝试在我的Android手机上运行测试。
我正在使用最新的appium windows exe 我使用以下代码:
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.*;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Test
{
public static void main(String[] args) throws MalformedURLException
{
WebDriver dr;
File app=new File("C://Users//TarunVats//Desktop//atoms.apk");
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "Xiaomi Mi3");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.4.4");
capabilities.setCapability("app",app.getAbsolutePath());
capabilities.setCapability("appPacakage", "com.AndroidTest");
capabilities.setCapability("appActivity", "com.Test.Main");
dr=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
dr.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
}
}
在外部罐中添加Gson-2.0 jar。用于appium的java client.jar。所有基于硒的罐都是进口的。我的手机处于调试模式。在eclipse DDMS显示我的手机已连接
仍然,我收到错误:
Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.remote.ErrorHandler.<init>(Lorg/openqa/selenium/remote/ErrorCodes;Z)V
at io.appium.java_client.AppiumDriver.<clinit>(AppiumDriver.java:46)
at Test.main(Test.java:29)
有人可以解释发生了什么吗?
答案 0 :(得分:0)
appPackage
功能存在问题。
你写了
capabilities.setCapability("appPacakage", "com.AndroidTest");
但需要
capabilities.setCapability("appPackage", "com.AndroidTest");