Thursday 22 July 2021

Appium: Native Context and Web-view context for Hybrid application | Entering the web view context


One of the core principles of Appium is that you shouldn't have to change your app to test it. In line with that methodology, it is possible to test hybrid apps the same way you can with Selenium for web apps. There is a bit of technical complexity required so that Appium knows whether you want to automate the native aspects of the app or the web views. But, thankfully, we can stay within the Selenium WebDriver protocol for everything.

Once the test is in a web view context the command set that is available is the full Selenium WebDriver API.

Entering the web view context

Here are the steps required to talk to a web view in your Appium test:

  1. Navigate to a portion of your app where a web view is active
  2. Retrieve the currently available contexts
    • This returns a list of contexts we can access, like 'NATIVE_APP' or 'WEBVIEW_1'
  3. Set the context with the id of the context you want to access
    • This puts your Appium session into a mode where all commands are interpreted as being intended for automating the web view, rather than the native portion of the app. For example, if you run getElementByTagName, it will operate on the DOM of the web view, rather than return native elements. Of course, certain WebDriver methods only make sense in one context or another, so in the wrong context you will receive an error message.
  4. To stop automating in the web view context and go back to automating the native portion of the app, simply set the context again with the native context id (generally 'NATIVE_APP') to leave the web context and once again access the native commands.

Automatically entering the web view context on session start

If your application begins in a web view, and you do not want to automate the native application before entering it, you can have Appium automatically enter the web view context on session initialization by setting the autoWebview desired capability to true.


Watch the complete video to understand in this video how we are going to  enter into the webview context 


Tuesday 13 July 2021

Android Uiautomator2 | Finding Elements using UiAutomator

The UiAutomator2 Driver for Android

From Appium official Github page about what they say:-

Appium's flagship support for automating Android apps is via the UiAutomator2 driver. (New to Appium? Read introduction to Appium drivers). This driver leverages Google's UiAutomator2 technology to facilitate automation on a device or emulator.

Development of the UiAutomator2 driver happens at the appium-uiautomator2-driver repo.

Older Android-based drivers include: * The UiAutomator Driver

Requirements and Support

In addition to Appium's general requirements:

  • Java 8 installed and configured correctly for your platform
  • Mac, Windows, or Linux OS with the ability to run the Android SDK
  • The minimum required Android SDK Build Tools version is 24

Further, the UiAutomator2 driver does not support Android versions below 5.0 (Lollipop, API level 21). If you are automating such versions, consider using the UiAutomator driver;


Below is the video tutorial on how to find elements using UiAutomator


Tuesday 6 July 2021

Automate Android , iOS, Windows UWP with Appium | Creating Desired Capabilities

Automating mobile apps

If you're interested in automating your web app in Mobile Safari on iOS or Chrome on Android, Appium can help you. Basically, you write a normal WebDriver test and use Appium as the Selenium server with a special set of desired capabilities.


Desired Capabilities are keys and values encoded in a JSON object, sent by Appium clients to the server when a new automation session is requested. They tell the Appium drivers all kinds of important things about how you want your test to work. Each Appium client builds capabilities in a way specific to the client's language, but at the end of the day, they are sent over to Appium as JSON objects.

Desired Capabilities can be scripted in the WebDriver test or set within the Appium Server GUI (via an Inspector Session)


Let’s consider an example of Desired Capabilities in Appium represented as a JSON object.

{
platformName”: Android”,
platformVersion”: 11.0”,
deviceName”: Samsung A50”,
automationName”: Appium”,
app”: path for the app under test
}
Using the above-mentioned Desired Capabilities, the user is instructing the drivers to start the test automation session for the app at the mentioned path on a Samsung A50 with Android version 11.0 using Appium.

In this video, we are going to create desired capabilities for Android, iOS, and Windows App. We are also going to see how to find the UDID of the iOS device and simulator. And how to find the bundle ID.




Interview Experience with AMAZON for the role of Quality Assurance Tester

This role was for Digital/ IoT/Mobile Application based testing :)  Amazon is a dream company and everyone wants to work for that company a...

Popular Posts