https://github.com/thecodetraveler/androidcheckboxsampleapp
A simple app to demonstrate how to interact with an Android CheckBox from a UITest
https://github.com/thecodetraveler/androidcheckboxsampleapp
Last synced: about 1 year ago
JSON representation
A simple app to demonstrate how to interact with an Android CheckBox from a UITest
- Host: GitHub
- URL: https://github.com/thecodetraveler/androidcheckboxsampleapp
- Owner: TheCodeTraveler
- License: mit
- Created: 2016-08-26T01:00:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-22T22:30:24.000Z (over 5 years ago)
- Last Synced: 2025-02-14T05:31:18.345Z (about 1 year ago)
- Language: C#
- Size: 64.5 KB
- Stars: 2
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AndroidCheckBoxSampleApp
This is a simple app to demonstrate how to interact with an Android CheckBox from a UITest.
To interact with an Android CheckBox from a UITest, you must use the [Invoke](https://docs.microsoft.com/dotnet/api/xamarin.uitest.queries.appquery.invoke?view=xamarin-uitest-sdk&WT.mc_id=mobile-0000-bramin#Xamarin_UITest_Queries_AppQuery_Invoke_System_String_) method to access the methods in the [native Java Android API](https://developer.android.com/reference/android/widget/CheckBox.html). In our `Invoke` statements, we can take advantage of `performClick()` to toggle the CheckBox, `setChecked(boolean checked)` to set the value of the CheckBox, and `isChecked()` to return a bool that is `true` when the CheckBox is checked and `false` when it is unchecked.
In the UITest project, I created a [ToggleCheckBox](https://github.com/brminnick/AndroidCheckBoxSampleApp/blob/master/CheckBoxSampleApp.UITest/Tests.cs#L128) method to toggle an individual CheckBox, a [IsCheckBoxChecked](https://github.com/brminnick/AndroidCheckBoxSampleApp/blob/master/CheckBoxSampleApp.UITest/Tests.cs#L134) method to return the CheckBox current status, and a [SetCheckBox](https://github.com/brminnick/AndroidCheckBoxSampleApp/blob/master/CheckBoxSampleApp.UITest/Tests.cs#L139) method to set the CheckBox status.