Appium对中文支持有问题已经是众所周之得了,但是今天用Appium编写一个创建Note的实例的时候发现Appium对含有英文和数字的字串输入也有问题。
比如如果想用driver.sendkeys来输入“Note1",事实上你会得到的是Note。实践中发现如果英文字串和数字之间加多一个空格就能解决问题,比如输入”Note 1",最终得到的就会是"Note1".
实践发现UIAutomator存在同样的问题,因为Appium底层调用的就是UIAutomator,所以最终的Bug应该是是属于UIAutomator这一边的。
以下Appium代码可以验证这个问题:
//Enter the note info and save it
WebElement text = driver.findElementByClassName("android.widget.EditText");
text.sendKeys("Note 1");
driver.sendKeyEvent(82);
el = driver.findElement(By.name("Save"));
el.click();
//Find out the new added note entry
List
entries = driver.findElements(By.className("android.widget.TextView"));
WebElement targetEntry = null;
for(WebElement entry : entries) {
if(entry.getText().equals("Note1")) {
targetEntry = entry;
break;
}
}