1:Original error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"]
解决方法:https://blog.csdn.net/u012106209/article/details/77012141
2:UiAutomator quit before it successfully launched) (WARNING: The server did not provide any stacktrace information
原因:UiAutomator手机端的端口被占用
解决方法:第一步 删除AppiumBootstrap.jar 位置 /data/local/tmp/
第二步 重启手机 再次启动Appium 启动脚本
3:A new session could not be created. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 24.31 second
解决方法:重启手机 Appium
4:elenium.SessionNotCreatedException: A new session could not be created. (Original error: Remote install failed: Failure [INSTALL_FAILED_USER_RESTRICTED: Install canceled by user]) (WARNING: The server did not provide any stacktrace information)
解决方法:
第一步:开启USB安装
第二步:执行脚本的时候 如果是第一次使用Appium安装APP 需要先安装下列两个APP (执行脚本后 根据手机提示进行即可)
5:脚本启动正常 元素也都有定位到 执行了click的操作 但是APP却没有对应的跳转
解决方法:参考下图 需要在"开发者选项"中把“USB调试”打开
再次执行代码 可以运行
package com.AutoAPP.APP;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
public class AppTest {
public static AndroidDriver initDriver(String appPackage,String appActivity) throws Exception{
DesiredCapabilities caps=new DesiredCapabilities();
//
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "anything");
caps.setCapability("appPackage", appPackage);
//要启动的应用的起始activity
caps.setCapability("appActivity", appActivity);
//resetKeyBoard是执行完测试后将设备的输入法重置回原有的输入法
caps.setCapability("unicodeKeyBoard", true);
caps.setCapability("resetKeyBoard", true);
//不对app进行重签名,因为有的app在重签名之后无法使用
caps.setCapability("noSign", true);
//设置session的超时时间
caps.setCapability("newCommandTimeout", 600);
caps.setCapability("udid", "2be8daaa9805");
//http://127.0.0.1:4723/wd/hub 为Appium的URL连接
return new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
AndroidDriver driver = initDriver("net.csdn.csdnplus","net.csdn.csdnplus.activity.SplashActivity");
Thread.sleep(10000);
driver.findElementByName("我的").click();
}
}
5:java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector
解决办法:引入下列依赖
com.google.guava
guava
21.0
https://blog.csdn.net/slow_wakler/article/details/73613021
6:Exception in thread "main" org.openqa.selenium.WebDriverException: ERROR running Appium command: write EPIPE
Command duration or timeout: 324 milliseconds
具体报错日志如下: 原因:启动Appium的命令后面没有加日志路径
正确操作:
String log = ">C:test.log";
String cmd = "appium -p "+key+" -bp "+value+" -U "+udid +log;
错误:
String cmd = "appium -p "+key+" -bp "+value+" -U "+udid;
Exception in thread "main" org.openqa.selenium.WebDriverException: ERROR running Appium command: write EPIPE
Command duration or timeout: 324 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'Anndy-PC', ip: '192.168.1.4', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_191'
Driver info: io.appium.java_client.android.AndroidDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:36)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:114)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:132)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:92)
at cn.AnndyTsal.PO.APP_PO.Base.initDriver.getDriver(initDriver.java:91)
at cn.AnndyTsal.PO.APP_PO.Base.DriverBase.(DriverBase.java:66)
at cn.AnndyTsal.PO.APP_PO.Base.DriverBase.main(DriverBase.java:163)