51Testing软件测试论坛

标题: appium清空输入框出错 [打印本页]

作者: 轻歌越野    时间: 2017-4-10 16:02
标题: appium清空输入框出错
代码如下:       Thread.sleep(5000);
            List<WebElement> inputs = ((FindsByAndroidUIAutomator) driver).findElementsByAndroidUIAutomator("new UiSelector().className("+"android.widget.EditText"+").index(1)");
              //List<WebElement> input = driver.findElementsByClassName("android.widget.EditText");
            WebElement account = inputs.get(0);
            account.click(); //选中输入框
            ((AndroidDriver) driver).sendKeyEvent(123);//将光标移到最后           
            String txt = account.getText(); //获取字符串长度           
            for(int i=0;i<txt.length();i++){
                   
                ((AndroidDriver) driver).sendKeyEvent(67);  
               
            }           
        //clear(account);
        account.sendKeys("solar@delta.com");

在 ((AndroidDriver) driver).sendKeyEvent(123);这行出错:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)


百度了好久,都不知道问题出在哪,亲们知道吗




作者: jingzizx    时间: 2017-4-11 07:55
帮顶
作者: 黑盒测试    时间: 2017-4-11 10:22
学习
作者: lamecho    时间: 2017-4-13 00:00
我是进来鄙视java的
作者: 梦想家    时间: 2017-4-13 09:45
有解决的么学习一下
作者: 轻歌越野    时间: 2017-4-13 09:50
本帖最后由 轻歌越野 于 2017-4-13 09:55 编辑

查看日志发现是这个问题:
info: [debug] Pushing command to appium work queue: ["pressKeyCode",{"keycode":1
23,"metastate":null}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action"
:"pressKeyCode","params":{"keycode":123,"metastate":null}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: pressKeyCode
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Inject
ing to another application requires INJECT_EVENTS permission"}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"
An unknown server-side error occurred while processing the command.","origValue"
:"Injecting to another application requires INJECT_EVENTS permission"},"sessionI
d":"100e1428-5c8f-4d92-b761-d300c3ec1dc6"}

然后找开发帮我获得了这个权限INJECT_EVENTS

还是没用,依然报这个错,已经快崩溃了





欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2