Appium對中文支持有問題已經(jīng)是眾所周之得了,但是今天用Appium編寫一個創(chuàng)建Note的實例的時候發(fā)現(xiàn)Appium對含有英文和數(shù)字的字串輸入也有問題。</span>
比如如果想用driver.sendkeys來輸入“Note1",事實上你會得到的是Note。實踐中發(fā)現(xiàn)如果英文字串和數(shù)字之間加多一個空格就能解決問題,比如輸入”Note 1",最終得到的就會是"Note1".
實踐發(fā)現(xiàn)UIAutomator存在同樣的問題,因為Appium底層調(diào)用的就是UIAutomator,所以最終的Bug應(yīng)該是是屬于UIAutomator這一邊的。
以下Appium代碼可以驗證這個問題:
//Enter the note info and save it webElement text = driver.findElementByClassName("android.widget.EditText"); <span style="color:#ff0000;"> text.sendKeys("Note 1");</span> driver.sendKeyEvent(82); el = driver.findElement(By.name("Save")); el.click(); //Find out the new added note entry List <WebElement> entries = driver.findElements(By.className("android.widget.TextView")); webElement targetEntry = null; for(WebElement entry : entries) { <span style="color:#ff0000;">if(entry.getText().equals("Note1")) </span>{ targetEntry = entry; break; } }