私有静态WebDriver驱动程序;
public static void main(String[] args)throws MalformedURLException, InterruptedException {
//System.setProperty("webdriver.gecko.driver", "D://Softwares/geckodriver.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
System.setProperty("webdriver.gecko.driver", "D://Softwares/geckodriver.exe");
//capabilities.setCapability("browserName", "Android");
capabilities.setCapability("platformVersion", "7.1.2");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("automationName","uiautomator2");
capabilities.setCapability("deviceName","emulator-5554");
capabilities.setCapability("appPackage", "com.android.camera");
capabilities.setCapability("appActivity","com.android.camera.Camera");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
//driver.quit();
}
线程“主”中的异常org.openqa.selenium.WebDriverException:处理命令时发生未知的服务器端错误。原始错误:执行adbExec时出错。原始错误:'命令'C:\ Users \ XXXXXX \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -P 5037 -s 4b9883b7cf40 shell pm clear com.android.camera'以代码1退出''; Stderr:“错误:java.lang.SecurityException:PID 20150没有权限android.permission.CLEAR_APP_USER_DATA来清除包com.android.camera的数据”。代码:“ 1” 生成信息:版本:'3.14.0',修订版本:'aacccce0',时间:'2018-08-02T20:05:20.749Z' 系统信息:主机:'XFACTORY-24',ip:'192.168.0.33',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'10 .0 .2' 驱动程序信息:driver.version:RemoteWebDriver remote stacktrace:UnknownError:处理命令时发生未知的服务器端错误。原始错误:执行adbExec时出错。原始错误:'命令'C:\ Users \ XXXXXX \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -P 5037 -s 4b9883b7cf40 shell pm clear com.android.camera'以代码1退出''; Stderr:“错误:java.lang.SecurityException:PID 20150没有权限android.permission.CLEAR_APP_USER_DATA来清除包com.android.camera的数据”。代码:“ 1” 在getResponseForW3CError(C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ node_modules \ appium \ node_modules \ appium-base-driver \ lib \ protocol \ errors.js:826:9) 在asyncHandler $(C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ node_modules \ appium \ node_modules \ appium-base-driver \ lib \ protocol \ protocol.js:404:37) 在tryCatch(C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ node_modules \ appium \ node_modules \ babel-runtime \ regenerator \ runtime.js:67:40) 在GeneratorFunctionPrototype.invoke上[作为_invoke](C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ node_modules \ appium \ node_modules \ babel-runtime \ regenerator \ runtime.js:315:22) 在GeneratorFunctionPrototype.prototype上。(匿名函数)[下一个](C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ node_modules \ appium \ node_modules \ babel-runtime \ regenerator \ runtime.js:100 :21) 在GeneratorFunctionPrototype.invoke(C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ node_modules \ appium \ node_modules \ babel-runtime \ regenerator \ runtime.js:136:37) 运行时(C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ webpack:\〜\ babel-polyfill \〜\ core-js \ modules \ es6.promise.js:75:1) 在C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ webpack:\〜\ babel-polyfill \〜\ core-js \ modules \ es6.promise.js:92:1 刷新时(C:\ Users \ XXXXXX \ AppData \ Local \ Programs \ Appium \ resources \ app \ webpack:\〜\ babel-polyfill \〜\ core-js \ modules_microtask.js:18:1) 在process._tickCallback(内部/进程/next_tick.js:61:11) 在java.base / jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(本地方法) 在java.base / jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(未知来源) 在java.base / jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(未知来源) 在java.base / java.lang.reflect.Constructor.newInstance(未知来源) 在org.openqa.selenium.remote.W3CHandshakeResponse.lambda $ new $ 0(W3CHandshakeResponse.java:57) 在org.openqa.selenium.remote.W3CHandshakeResponse.lambda $ getResponseFunction $ 2(W3CHandshakeResponse.java:104) 在org.openqa.selenium.remote.ProtocolHandshake.lambda $ createSession $ 0(ProtocolHandshake.java:122) 在java.base / java.util.stream.ReferencePipeline $ 3 $ 1.accept(未知来源) 在java.base / java.util.Spliterators $ ArraySpliterator.tryAdvance(未知来源) 在java.base / java.util.stream.ReferencePipeline.forEachWithCancel(未知源) 在java.base / java.util.stream.AbstractPipeline.copyIntoWithCancel(未知源) 在java.base / java.util.stream.AbstractPipeline.copyInto(未知源) 在java.base / java.util.stream.AbstractPipeline.wrapAndCopyInto(未知源) 在java.base / java.util.stream.FindOps $ FindOp.evaluateSequential(未知源) 在java.base / java.util.stream.AbstractPipeline.evaluate(未知来源) 在java.base / java.util.stream.ReferencePipeline.findFirst(未知来源) 在org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125) 在org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73) 在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) 在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212) 在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:130) 在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:143) 在testAp.FC.main(FC.java:31)