Understanding the most commonly used Xamarin.UITest testing methods

In this section, we will learn about some of the commonly used methods that we can use with the Xamarin.UITest framework, which provides you with a way in which you can automate the interactions between your Android or iOS apps, using either C# or F#, as well as the NUnit testing framework.

The following table describes some of the more commonly used methods and the ones that we will be using to test the TrackMyWalks app:

UITest methods

Description

Screenshot()

The Screenshot method is used to take a screenshot of the current state of the app.

Tap()

The Tap method is used to send a tap to interact with a specific element that is contained on the app's current screen.

EnterText()

The EnterText method is used to populate text within a specific element that is contained on the app's current screen.

ClearText()

The ClearText method is used to remove text within a specific element that is contained on the app's current screen.

Query()

The Query method is used to find a specific element or all elements that are contained within the app's current screen.

Repl()

The Repl method is commonly used to interact in real-time with the app through the terminal command line using the UITest APIs.

WaitForElement()

The WaitForElement method is used to pause the execution of the current running test, until a specific element appears on the app's current screen, within a specific timeout period.

 

Using methods such as Query and WaitForElement returns an AppResult[] array object that you can use to determine the results of a call. An example would be that, if you use the Query method call that returns an empty result, you can be sure that the element doesn't exist within the app's current screen.

The Xamarin UITest framework only provides support for both the iOS and Android platforms and doesn't provide support for the UWP platform.

The following table describes the methods relating to the AppQuery class that are used by the Query and WaitForElement methods of the IApp interface:

AppQuery Methods

Description

Class()

The Class method is used to find elements that are contained within the app's current screen based on their class type.

Marked()

The Marked method is used to find elements that are contained within the app's current screen, by referring to them by their text values or identifier.

Css()

The Css method is used to perform CSS selector operations on the contents of a WebView that are contained on the app's current screen.


For more information on the Xamarin.UITest class methods, refer to the Xamarin developer documentation at https://developer.xamarin.com/api/namespace/Xamarin.UITest/.

Now that you have some insight into some of the most commonly used UITest methods, we can start to create and implement our UI tests using some of the methods of the Xamarin.UITest framework that we will be covering over the next couple of sections.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181