Deploying a stand for iOS UI testing based on Selenoid

Hello everyone! My name is Pavel, I am a technical testing leader in the mobile development direction. In my previous article, I described how we deployed a test stand for Android testing based on Selenoid, and why we chose this particular tool.

The next step was to deploy a similar setup for iOS UI testing.

Here I would like to note that there is no ready-made solution for Apple devices, both for Android, and the Selenoid documentation does not contain information for iOS. Therefore, I relied on the Selenoid article: Launching Appium UI tests on iOS. Part 2. However, we had a different story, we raised a stand for UI testing on real iPhones.

Preparation

The first thing we need to do is install all the necessary packages and applications.

Let's start with brew. This application allows you to install packages that Apple does not provide. Let's go to website or run the command in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Next, install the npm package manager, which is part of Node.js. To do this, go to websitedownload the file for installation or execute the command in the terminal:

brew install npm

The next step is to install Appium. There are no options here – install via terminal:

sudo npm install -g appium

We also need to install appium-doctor to check at the end that we haven't missed anything when setting up Appium. Similarly, we run the command in the terminal:

sudo npm install -g appium-doctor

Now on Mac we need to install Сarthage. Also in two ways: via installer or terminal:

brew install carthage

And finally, open the AppStore and install XCode.

While we are downloading and installing the application, we can go to website and download the latest version of Selenoid for MacOS. If you have Intel, then you need the AMD version for M1, M2, etc. Accordingly, you need the ARM version.

Next we move on to website and by analogy with Selenoid, download the latest version of Selenoid UI.

The preparation is complete – you can proceed to the setup.

Setting

First we need to make sure that there are no errors when running appium-doctor. First, install Xcode Command Line Tools.

Command in terminal:

xcode-select --install

After installation, check:

xcode-select -p

You should see the following line in the terminal:

/Applications/Xcode.app/Contents/Developer

Launch appium-doctor:

appium-dcotor --ios

After which you should see something like this:

Appium is configured, now you can proceed to setting up the configuration. Create a config for Appium and a config for Selenoid:

{
  "ios": {
    "default": "iPhone X",
    "versions": {
      "iPhone X": {
        "image": ["appium", "--config", "/Users/mobilefarm.am/selenoid/config/appium/iphonex.json"]
      },
      "iPhone 6s": {
        "image": ["appium", "--config", "/Users/mobilefarm.am/selenoid/config/appium/iphone6s.json"]
      }
    }
  }
}

We launch Selenoid with the following parameters:

./selenoid -disable-docker -conf config/browsers.json -limit 20 -retry-count 1000 -video-output-dir video -log-output-dir logs -max-timeout 20m -session-attempt-timeout 15m -timeout 10m -service-startup-timeout 10m

And Selenoid UI:

./selenoid-ui --selenoid-uri=http://localhost:4444

Let's check that Selenoid has started successfully:

 http://localhost:8080

The standard UI should open in the browser:

Let's move on to the most interesting part…

Installing drivers on devices

The most problematic part is setting up the test stand. Open the terminal and run the command:

appium driver run xcuitest open-wda

The WebDriverAgent project should open.

You need to go to XcodePreferencesAccounts and add an AppleID account. Then:

  • return to project;

  • In chapter Signing & Capabilities select your previously added account in the field Team;

  • and replace in the field Bundle Identifier to its meaning.

Run the build and then check ProductTest. The driver icon should appear on the device.

On iPhone, go to SettingsMainProfiles and Device Management and press Trust the developer.

Possible problems and solutions

When trying to connect via Appium Inspector, we encountered the following error:

Close XCode and download from site zip file of the latest version. Unpack the archive and drop the contents of the archive into the directory ~/.appium/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/having previously cleared this folder.

Now we launch the wda project and rebuild the driver for the device. Close XCode again, reinstall the project.

sudo appium driver uninstall xcuitest
sudo appium driver install xcuitest

We open the project and once again compile the drivers on the iPhone – we try to connect via Appium Inspector. After such manipulations, the connection was successful and Safari launched on the devices.

That's all for now. Next we plan to set up Go GGR Router so that we have a single point of connection. Thanks for your attention.

Similar Posts

Leave a Reply

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