无法启动Chrome浏览器appium@1.8 Android(7.0)

时间:2018-05-14 09:11:15

标签: appium appium-android

我正在尝试在Android手机中启动Chrome浏览器。我得到了这个例外。

Error while killing uiAutomator: Error: Unable to kill uiautomator processes. Original error: Error executing adbExec. Original error: 'Command '/Users/smuralik/Library/Android/sdk/platform-tools/adb -P 5037 -s 988a1b474250413542 shell kill -0 21431' exited with code 1'; Stderr: '/system/bin/sh: kill: 21431: Operation not permitted'; Code: '1'
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","988a1b474250413542","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.android.chrome","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] UiAutomator exited unexpectedly with code 255, signal null
[debug] [UiAutomator] Moving to state 'stopped'
Unhandled rejection Error: UiAUtomator shut down unexpectedly
    at AndroidBootstrap.callee$2$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-android-bootstrap/lib/bootstrap.js:176:42)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at new Promise (<anonymous>)
    at new F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at UiAutomator.callee$2$0 (/usr/local/lib/node_modules/appium/node_modules/appium-android-bootstrap/build/lib/bootstrap.js:353:42)
    at emitOne (events.js:116:13)
    at UiAutomator.emit (events.js:211:7)
    at UiAutomator.changeState (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator/lib/uiautomator.js:85:10)
    at SubProcess.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/appium-uiautomator/lib/uiautomator.js:47:14)
    at emitTwo (events.js:126:13)
    at SubProcess.emit (events.js:214:7)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/teen_process/lib/teen_process.js:240:14)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

以下是我的驱动程序初始化代码:

public static void main(String[] args) {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("deviceName", "My Phone");
        caps.setCapability("platformName", "Android");
        caps.setCapability("browserName", "Chrome");
        caps.setCapability("noReset", true);


        AppiumDriver<MobileElement> driver = null;
        try {
            driver = new AndroidDriver<>(new URL("http://127.0.0.1:4501/wd/hub"), caps);

        } catch (MalformedURLException e) {
            System.out.println(e.getMessage());
        }
        driver.get("http://www.google.com");
    }

我正在使用Appium1.8和最新的android sdk。

感谢您的帮助。感谢。

2 个答案:

答案 0 :(得分:1)

我通过在功能中传递uiautomator2来解决这个问题。

caps.setCapability("automationName", "uiautomator2");

现在appium选择了uiautomator2而不是uiautomator,浏览器成功推出。

答案 1 :(得分:0)

试试这个

 public static void main(String[] args) {
            DesiredCapabilities caps = new DesiredCapabilities();
            caps.setCapability("deviceName", "My Phone");
            caps.setCapability("platformName", "");
            caps.setCapability("browserName", "Chrome");
            caps.setCapability("noReset", "true");


            AppiumDriver<MobileElement> driver = null;
            try {
                driver = new AndroidDriver<>(new URL("http://127.0.0.1:4501/wd/hub"), caps);

            } catch (MalformedURLException e) {
                System.out.println(e.getMessage());
            }
            driver.get("http://www.google.com");
        }