2012-02-07 48 views
2

我在測試我的應用程序。在那裏,我有一個文本框,首先我輸入字母,然後我將鍵盤更改爲數字並輸入數字,這樣我得到一個字符串qwerty123。但UIAutomation不理解這一點。當我運行這個腳本時,它說"tap point object is required"在線"target.frontMostApp().keyboard().typeString("qwerty123\n");"我怎樣才能解釋它的鍵盤已經改變?在UIAutomation中更改鍵盤

回答

0

您可以設置的setValue文本字段的值,這將帶來鍵盤窗口,然後點擊完成元素在鍵盤

textfield.setValue(addressLink); target.frontMostApp().keyboard().elements()["done"].tap();

You can also do following 

target.frontMostApp().keyboard().elements()["q"].tap(); target.frontMostApp().keyboard().elements()["w"].tap(); target.frontMostApp().keyboard().elements()["more"].tap(); target.frontMostApp().keyboard().elements()["1"].tap(); target.frontMostApp().keyboard().elements()["2"].tap(); target.frontMostApp().keyboard().elements()["done"].tap();

+0

它區分大小寫。它應該是「完成」,而不是「完成」 – neo 2013-11-18 17:43:30

0

要設置任何字符串,只需使用如下:

window.secureTextFields()[0].setValue(""); //Sets textfield to empty. 
app.keyboard().typeString(qwerty123); //Type any string you want 
app.keyboard().typeString("\n"); //Press 'Enter'. Also can go in the above line.