Appium 【已解决】OPPO 4.3 系统,输入 text 时各字符总是输入两次

water · 2015年05月11日 · 最后由 water 回复于 2015年05月11日 · 1340 次阅读

先说一下环境,我们是使用 C# Appium1.3.1,对各种方法进行了封装,其中输入 text 时是使用了下面封装的一个 ADBCommand 方法,调用"adb shell input text xxxxx"的命令行以输入 text。目前已经在 Samsung(4.4.2), 华为 (4.4.2),魅族 MX4(4.4.4) 进行调试,输入都没有什么问题。现在调试 OPPO Android4.3 系统时,输入 text 总是会出现两次,例如输入 “http”,实际在页面上输入的却是 “hhttttpp”,或者 “hhtttptp”。
找了很久没有找到原因,来论坛向大神求助一下 T_T
语言:C#
Appium 服务器版本:1.3.1
系统型号版本: OPPO-X9007, Android4.3
输入法:系统自带输入法
问题描述:使用封装的 adb shell input text,或者 Appium 自带的 SendKeys() 方法,都会出现各字符出现了两次的情况。
对比:直接打开一个 cmd,调用命令"adb shell input text http",是可以正常输入 http 的。

目前分析:在执行机上运行 bootstrap:

adb.exe -s de5e5976 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap

分析 2:然后执行下列的 ADBCommand 方法,输入 http,果然重现出了这个问题。看来 OPPO 系统中 bootstrap 和 ADB 同时接受到了命令并且执行了,因此输入成了 hhttttpp。目前还没有找到好的解决办法,继续努力下- 3-

解决方案:进一步调试发现是 OPPO 自带的搜狗输入法(1.0.0)的问题,换成另外一种输入法,这个问题就解决了!

我封装的 ADBCommand 方法如下(C#):

public static void ADBCommand(string cmd)
        {
            Process process = new Process();

            process.StartInfo.FileName = @"cmd.exe";
            process.StartInfo.Arguments = string.Format("/c adb shell {0}", cmd);

            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardInput = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;

            process.Start();
            process.WaitForExit();
            Thread.Sleep(500);//为了调试增加一个sleep。
            process.Close();
        }
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 3 条回复 时间 点赞

是 OPPO 系列是这样还是只有 OPPO Android4.3 是这样?反正 OPPO 的系统很多坑。各种稀奇的问题。

#1 楼 @snake 目前只有一台 OPPO,所以没测其他的~ 我单独封装运行一个 ADBCommand 去执行同样的代码又没有问题~ 猜测像是 bootstrap 和 OPPO 自带的一个 adb 都同时执行了一个 input 命令,所以输出两条。目前还在想办法定位哎~

#1 楼 @snake 刚才单独跑了一下 bootstrap,然后执行 adb 命令,果然重现出了问题,看来我猜测没错~

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册