开发者

How to access the element of second page in UI automation (iPhone)?

开发者 https://www.devze.com 2023-02-10 18:48 出处:网络
My app has a main screen where i have button to go to login scre开发者_StackOverflowen. On pressing login button it goes to second screen which is login screen.

My app has a main screen where i have button to go to login scre开发者_StackOverflowen. On pressing login button it goes to second screen which is login screen. In the login screen i have a submit button which is inside a table view. I want to tap this Submit. What approach i should use. Or more precisely in same java script hot to access the elements of second scree.


First you have to ensure that the button is accessable. Either set the Accessability property in Interface Builder (Identity Inspector - last Tab) and give the button an appropriate Accessability Label. If you don't use Interface Builder you can set the property on the button programaticaly.

Now in the script you can call

mainWindow.buttons()["name of the accessability label"].tap();

mainwindow is:

var target = UIATarget.localTarget();
var application = target.frontMostApp();
var mainWindow = application.mainWindow();

Make also sure that the button is visible. The button has to be the deepest element in the view hierarchie which is marked accessable. If the view containing the button is enabled as accessable, it would hide the accessability of the button (which is a subview).

You can log all visible elements in the screen by

mainwindow.logElementTree();

Moreover, you always can use one single script. The mainWindow.elements() references the view which is shown at a certain moment.


Get the tableView object of the window, then get the cells of that tableView. Now grab the buttons array of the cell with the submit button and tap the button. Something like that:

var submit = window.tableViews()[0].cells()[2].buttons()[0];
submit.tap();
0

精彩评论

暂无评论...
验证码 换一张
取 消