By Guy Heimann
Progressive Web Apps (PWA) are creating waves in the mobile application community. Allowing a web application to act like a mobile application allows the user to know that his application is in-sync with the service provider's web-site services. Apple's Safari browser has introduced, in iOS 11.3, support for configuring any website, whose creator defined the ability to configure the site as a PWA, to install the corresponding PWA on the home page of your iOS device.
Perfecto Lab provides the tools to launch, test, and close the PWA on the iOS device. Whether you use Appium or Perfecto's Native Automation you can test the PWA as if it were a hybrid application without performing any instrumentation.
This article does not address how to create the PWA, but, rather with how one works on iOS and how you can automate it using the Perfecto Lab.
When using the Safari browser, it’s possible to generate a special shortcut to the current open page, using the share tool that Safari supplies in the status line of the display (see below):
To install the PWA:
As we outlined, the PWA is not coupled to Safari but, on the other hand, it is not a unique application. Therefore, to test it, user must:
Meaning that the application cannot be launched from the Desired Capabilities, like a native application, but should be considered a mobile hybrid application that runs in an iOS environment (without Safari).
Use the Perfecto Extension Command mobile:pwa:start to launch the PWA with the displayName as a parameter.
The display name is the label of the PWA icon on the home page:
HashMap<String, String> pwaParams = new HashMap<String, String>(); pwaParams.put("displayName", "Smaller Pics"); driver.executeScript("mobile:pwa:start", pwaParams);
Use Perfecto Extension Command mobile:pwa:stop to close the PWA (no parameters needed):
Note: The Stop PWA command will only work if the PWA is running in the foreground at time of command execution, otherwise the command will fail with “Cannot close application. Application is not running.”
The Perfecto Lab considers the PWA as if it were a hybrid application, meaning:
The website user interface elements are all DOM elements, and should be accessed (via XPath) using the WEBVIEW context.
The application wrapper elements (for example, application header), and the XCUIElementTypeWebViewthat encapsulates the website are all native application elements, and should be accessed (via XPath) using the NATIVE_APP context.
driver.context("NATIVE_APP"); RemoteWebElement element = (RemoteWebElement)driver.findElementByXPath("//XCUIElementTypeWebView"); String elementID = element.getId(); // Outer WebView element can be scrolled using the scroll object command HashMap<String, String> scrollObject = new HashMap<String, String>(); scrollObject.put("element", elementID); scrollObject.put("direction", "down"); driver.executeScript("mobile:scroll", scrollObject);
The Object Spy will identify the UI Elements of the PWA and provide accurate placement of the elements to support using the Native Automation functions and commands to automate the application functionality.
The following limitations exist in the current version of the Perfecto support for PWA automation: