Forum Xamarin Test Cloud (Read Only)

Examples of Invoke method usage

I would be really thankful if you can share your example. How can I use Invoke method? Can I find some list of methods that can be used as Invoke method parameter? I found the way to get text color on Android, but on iOS it doesn't work.
Do I need to create my own backdoors and Invoke it to get text color and other simple things?


  • ShantimohanElchuriShantimohanElchuri USMember ✭✭✭✭✭

    One example of using Invoke to set a date in a DatePIcker, as used by me, is:

    if (platform == Platform.Android)
        // Wait for DatePicker animation to complete
        app.WaitForElement(x => x.Marked("dpMyDate"), "Timed out", TimeSpan.FromSeconds(timeoutSeconds));
        // Invoke updateDate native Android method on displayed DatePicker
            * In the github project
            *   the parts of the date are used directly as below:
            *   app.Query(x => x.Class("DatePicker").Invoke("updateDate", date.Year, date.Month, date.Day));
            * But actually that didn't work. I don't know why but the date.Month has to be decremented.
        app.Query(x => x.Class("DatePicker").Invoke("updateDate", date.Year, date.Month - 1, date.Day));
        // Tap Ok button to close the DatePicker
        // Wait for DatePicker animation to complete
        app.WaitForElement(x => x.Class("UIPickerView"));
        // Invoke selectRow native iOS method to set the desired date
        app.Query(x => x.Class("UIPickerView").Invoke("selectRow", date.Month - 1, "inComponent", 0, "animated", true));
        app.Query(x => x.Class("UIPickerView").Invoke("selectRow", date.Day - 1, "inComponent", 1, "animated", true));
        app.Query(x => x.Class("UIPickerView").Invoke("selectRow", date.Year - 1, "inComponent", 2, "animated", true));
        // Tap Done button to close the DatePicker
        app.Tap(x => x.Class("UIToolbarTextButton"));

    Unfortunately, I am also looking for the list of methods that can be invoked.

  • EmrahDautbegovicEmrahDautbegovic USMember ✭✭

    @ShantimohanElchuri Thanks for your response. If I find out something, I'll let you know.

  • AllanTeagueAllanTeague USMember

    Are there any other useful examples other than a DatePicker? This one is always used and I would like to know if there is a list of Default methods listed for Invoke....

Sign In or Register to comment.