Continuous monitoring of automated tests run is not possible and what if the AUT is crashed midway during run having 500+ cases.

As a solution to this we need to have an automated process in place to keep track. This is possible with “mobile: queryAppState” method in XCUITest, lets see how we can achieve this to ensure app stability and quality.

The code works on:

We will be using Java, Page Object Model and Cucumber to accomplish this.

PageClass.java

// get…


Switching ON/OFF WiFi on iOS Device

iPhone 7, 8 device used. The code works on:

Toggle WiFi using iOS Control Center

We will be using Java, Page Object Model and Cucumber to accomplish this.

PageClass.java

// WiFi locator on control center
private
String WiFi_BUTTON_CONTROL_CENTER = "wifi-button";
// locator for closing control center
private String CLOSE_CONTROL_CENTER_XPATH = "//XCUIElementTypeOther[@name=\"ControlCenterView\"]/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]";
public MobileElement getWifiButtonOnControlCenter() { return MobileConnector.getDriver().findElementByAccessibilityId(WiFi_BUTTON_CONTROL_CENTER); }// method to get current WiFi status, returns 0,1
public String getWifiStatusOnControlCenter()
{
String wifiStatus;
wifiStatus = getWifiButtonOnControlCenter().getAttribute("value");
System.out.println("Current …


Switch ON/OFF WiFi on iOS Device.

The code works on:
* iOS 13.6
* Appium 1.17
* XCode 11.6

Toggle WiFi using iOS Settings App

We will be using Java, Page Object Model and Cucumber to accomplish this.

PageClass.java

private String BUNDLE_ID_SETTINGS = "com.apple.Preferences";//locator for WiFi cell in settings app
private String WIFI_CELL_XPATH = "//XCUIElementTypeStaticText[@name=\"Wi-Fi\"]";
//locator for WiFi switch to turn on/off
private String WIFI_SWITCH_XPATH = "//XCUIElementTypeSwitch[@name=\"Wi-Fi\"]";
public String getSettingsBundleID() { return BUNDLE_ID_SETTINGS; }public MobileElement getWiFiCell() { return MobileConnector.getDriver().findElementByXPath(WIFI_CELL_XPATH); }public…

Shujaat Ali

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store