aquality-automation / aquality-appium-mobile-dotnet-template

Template project for aquality-appium-mobile-dotnet library.
https://github.com/aquality-automation/aquality-appium-mobile-dotnet
Apache License 2.0
5 stars 3 forks source link

Help needed : Testing Keyboard Functionality Across Input Fields in Aquality Appium with C# #19

Closed aarif313 closed 6 months ago

aarif313 commented 6 months ago

There's a necessity to ensure that the appropriate keyboard format is displayed when accessing various input fields, along with verifying the correctness of the displayed keys.

For instance, when opening a textbox for email input, an alphanumeric keyboard should be displayed. Similarly, when entering a mobile number, the keyboard should be numeric, containing all necessary numeric keys. How can this validation process be effectively implemented in Aquality Appium with C#?

Thank you.

Refer following screenshot for better clarity:

keyboards
mialeska commented 6 months ago

Hi @aarif313 ! I would like to notice that Aquality Appium Mobile framework doesn't limit you from using pure Appium functions if you need to. So, if you know how to solve this task with Appium, it should be solved the same way within Aquality framework. For example, to wait for keyboard to be shown after click, you can use

AqualityServices.ConditionalWait.WaitFor(driver => ((IHidesKeyboard)driver).IsKeyboardShown(), message: "Keyboard is not shown");

Regarding your specific task - the general ideal would be to interact with keyboard as with elements:

  1. By default, iOS keyboard visible in page source (usually under the tag "XCUIElementTypeKeyboard", while Android keyboard is not. To make Android keyboard visible in page source, please add "enableMultiWindows": true in android capabilities section of your settings.json. You would see keyboard elements in the page layout with package="com.google.android.inputmethod.latin" or similar. image image

  2. Describe page objects with needed elements and their locators, each keyboard type could be located in the separate screen form. Identify elements that differ from type to type and allow you to uniquely identify which keyboard type is opened.

  3. Assert that needed items are present or absent as you usually do in your tests.

  4. (Optional) You can use visual testing functionality of Aquality framework to check that screen form contains necessary items and they look as expected. To do so, firstly describe page object with unique elements, secondly execute yourScreen.Dump.Save($"{yourScreen.Name}_{AqualityServices.ApplicationProfile.PlatformName}"); to save expected screenshots, add these files to your solution, and finally in test you can add comand yourScreen.Dump.Compare($"{yourScreen.Name}_{AqualityServices.ApplicationProfile.PlatformName}") - result should be 0 if form looks the same. or If you need to compare single element screenshot with the expected image, you can use interface yourElement.Visual.GetDifference(screenshotFileInfo.ReadImage()); You can take screenshot of some element using interface yourElement.Visual.Image.Save(yourElement.Name);. or You can use our image comparator to get difference % of two images: AqualityServices.Get<IImageComparator>().PercentageDifference(image, theOtherOne); or You can find element by image using Appium Images plugin functionality, more info here: https://github.com/appium/appium/tree/master/packages/images-plugin

aarif313 commented 6 months ago

Dear @mialeska,

I wanted to express my gratitude for your assistance.

The primary reason for opening this ticket was to acquire the information you provided in point number 1. (To make the Android keyboard visible in the page source, please add "enableMultiWindows": true in the android capabilities section of your settings.json)

I'm pleased to inform you that it's now working as expected, and I can successfully inspect individual keys of the keyboard.

Thank you once again for your invaluable support.

Regards, Aarif