Search code examples
iphoneiosios-ui-automation

UI Automation :- How to click button using javascript of a screen which is not the main screen (iPhone)?


want to click a button through javascript for testing purpose. i am able to click the button which is on first page, but dont have idea how to click button on second page which comes after clicking button on first page.


Solution

  • You just need a reference to that button on the second page -- so you repeat the process from the first page. Probably, you did something like this (this code is from my app using a tab bar controller):

     // Now tap the add button
     var navBar = mainWindow.navigationBar();
     navBar.buttons()["Add"].tap();
    
     // Now the app loads a new page
     // Get the nav bar again (it would have changed after the tap above)
     navBar = mainWindow.navigationBar();
    

    So, the answer is easy -- just call back to the same functions, they will return whatever's on screen at the moment.