我试图在appium 1.1.0上运行自动化,但由于以下错误而无法启动自动化。我尝试在appium上使用selendroid模式在真实设备上运行自动化。
以下是我在自动化过程中执行的步骤:
Selendroid服务器:
XXXXX+ 14000 2480 0 18:30 pts/0 00:00:01 java -jar /home/XXXXXX/Selendroid/selendroid-standalone-0.10.0-with-dependencies.jar -aut /home/XXXXX/Selendroid/en-android.apk -selendroidServerPort 9001
Appium服务器:
XXXXX+ 14001 2480 0 18:30 pts/0 00:00:01 node /home/XXXXXX/.linuxbrew/bin/appium -q -p 6001 -bp 4001 -U cff19ff1e200dbe --selendroid-port 9001
使用Maven开始自动化:
mvn clean install -Dappium_port=6001
Appium功能:
private static String url = "http://localhost:"
+ System.getProperty("appium_port") + "/wd/hub";
private AppiumDriver driver;
private static DesiredCapabilities capabilities;
public void setUpCapabilities() throws Exception {
capabilities = new DesiredCapabilities();
File app = new File("en-android.apk");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("automationName", "Selendroid");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appActivity", ".gui.StartActivity");
capabilities.setCapability("appPackage","test");
}
public AppiumDriver automationInit() throws Exception {
driver = new AppiumDriver(new URL(url), capabilities);
return driver;
}
堆栈追踪:
java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:99)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:41)
at test.utils.TestUtility.automationInit(TestUtility.java:40)
请指导我如何解决此问题?在真实设备上运行测试时,appium功能有什么问题吗?
谢谢,
Priyank Shah
答案 0 :(得分:0)
我认为这与您在项目上的导入有关。 jar中缺少“org / apache / http / conn / SchemePortResolver”。可能是因为appium需要它。 我建议切换到maven项目并保留一个看起来像这样的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ProjectName</groupId>
<artifactId>ProjectName</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.42.1</version>
</dependency>
<dependency>
<groupId>io.selendroid</groupId>
<version>0.9.0</version>
<artifactId>selendroid-standalone</artifactId>
</dependency>
<dependency>
<groupId>io.selendroid</groupId>
<version>0.9.0</version>
<artifactId>selendroid-client</artifactId>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>
</project>
正确同步项目并让maven导入jar后,您不应该看到这些类型的问题。 IntelliJ完成了大部分工作,并强烈建议IDE执行此操作