Developing a hybrid solution with KIF and UIAutomation frameworks

Will KIF support targeting elements in WKWebView ?
By now, you must have already known that KIF wouldn’t support accessing and tapping elements in WKWebView. This would surely cause a lot of problems for automation tests which were written to access UIWebView.

[tester waitForViewWithAccessibilityLabel:@”SIGN IN”];

The above call will surely fail in WKWebView. In most cases, the login screen would be written in HTML to make it work in all platforms and make it compatible with single sign on. Google and Yahoo are some of the examples. To solve this either, you can keep the app always logged in, which isn’t good since your missing out on the complete UX flow. The next step would be integrating UIAutomation Framework.
The best part of this framework is, we are able to integrate it with Jenkins and its got an awesome CLI. The way we are going to do this is as follows-

  1. Open instruments.
  2. Record the test or write your own test in javascript.
  3. Copy the script into a file. Let’s consider our tests are saved in login.js.
  4. Write the final command as follows
    1. instruments -t “/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstr
      ument.xrplugin/Contents/Resources/Automation.tracetemplate”
      “~/Library/Developer/CoreSimulator/Devices/522D3108-BB58-4A46-BA46-0CEA2397C93A/data/Containers/Bundle/
      Application/B08911DC-67EB-41E5-A7D6-94369A099F81/test.app”
      -e UIASCRIPT “/Users/darshan/Documents/work/deadcode/login.js”
      -e UIARESULTSPATH “/Users/darshan/Documents/work/deadcode/login_result.txt” -w “iPhone 6s Plus (9.0)”
    2. You can also use helper scripts https://github.com/idStar/ui-automation-runner
  5. The above scripts can be integrated into Jenkins as the first part.

In

Leave a Reply

Your email address will not be published. Required fields are marked *