Automating Hybrid Apps

Go back to tutorial

Automating Hybrid Apps

We will start by understanding the basics of Automating Hybrid Apps and the process involved. First of all we should understand that the core principles of Appium. As per the  principle, you must not change your app to test it. Therefore, keeping this in mind, it is possible to test hybrid apps the same way you can with Selenium for web apps. But, given the technical complexity so that Appium knows whether you want to automate the native aspects of the app or the web views. In general, we can stay within the Selenium WebDriver protocol for everything.Therefore, after the test is in a web view context, the command set that is available is the full Selenium WebDriver API.

How to enter the web view context?

We will now elaborate the steps required to talk to a web view in your Appium test –

  • Firstly, you must navigate to a portion of your app where a web view is active
  • Secondly, you must try to retrieve the currently available contexts
  • Then, it will return a list of contexts we can access, like ‘NATIVE_APP’ or ‘WEBVIEW_1’
  • Thereafter, you should set the context with the id of the context you want to access
  • Further, this will put your Appium session into a mode where all commands are interpreted as being intended for automating the web view.
  • Lastly, in order to stop automating in the web view context and go back to automating the native portion of the app. You will be required to set the context again with the native context id leave the web context and then again access the native commands.

How to enter the web view context automatically?

We will now discuss the process to enter the web view context automatically, to session start without automating the native application before entering it. This can be done by entering the web view context on session initialization by setting the autoWebview desired capability to true.

Process of Automating hybrid iOS apps

Steps involved in automating Hybrid iOS apps

  • At first, you must interact with a web view Appium
  • Secondly, you must establish a connection using a custom remote debugger.
  • Thereafter, while executing against a simulator this connection is established directly as the simulator and the Appium server are on the same machine.
  • Further, Appium can automate WkWebView and UIWebView elements. But, it is not currently able to handle SafariViewController elements.
  • After setting your desired capabilities then start an Appium session.

Process of executing against an iOS real device

In the process of executing against an iOS real device, Appium is unable to access the web view directly. Therefore the connection has to be established through the USB cable. Further, to establish this connection we use the ios-webkit-debugger-proxy. Thereafter, you can start an Appium test session and follow the generalized instructions above.

 

Enrich your profile and become Job Ready. Practice and Prepare for Mobile Testing (Appium) Exam Now!

Get expert advice and hundreds of Free Test – Try Mobile Testing (Appium) Practice Questions Now!

Go back to tutorial

Get industry recognized certification – Contact us

Menu