Automatically type text into text box and click button on iOS

I made an iOS app using Ionic Framework (https://appsto.re/cn/EY8s7.i). Is it possible to simulate user input to that app?

For example, user clicks QQ login button in my app, and my app opens the facebook authentication page inside the in-app browser. Now I want the app automatically fill the username and password to the authentication window and hit the "Login" button.

How can I achieve it?

I suppose you want to accomplish this to test your app and some of its functionalities?

If so, you should use Angular Protractor for this kind of testing.

Protractor is a Node.js program, and runs end-to-end tests that are also written in JavaScript and run with node. Protractor uses WebDriver to control browsers and simulate user actions.

Here's an example:

describe('TODO list', function() {
    it('should filter results', function() {

        // Find the element with ng-model="user" and type "jacksparrow" into it
        element(by.model('user')).sendKeys('jacksparrow');

        // Find the first (and only) button on the page and click it
        element(by.css(':button')).click();

        // Verify that there are 10 tasks
        expect(element.all(by.repeater('task in tasks')).count()).toEqual(10);

        // Enter 'groceries' into the element with ng-model="filterText"
        element(by.model('filterText')).sendKeys('groceries');

        // Verify that now there is only one item in the task list
        expect(element.all(by.repeater('task in tasks')).count()).toEqual(1);
    });
});

More info about this matter can be found at AngularJS end-to-end testing.