Selenium Grid for mobile automated testing with Appium (Part II)

    In my previous blog post, it was described how Selenium Grid and Appium can be used for creating local mobile device farm. In this blog is discussed Jenkins configuration that will support built grid of mobile devices.

    Jenkins installation and basic configuration

    Latest version of Jenkins can be downloaded from the official site: https://jenkins.io/ . The easiest way to install Jenkins on Windows is using Windows Installer Package (.msi). By default Jenkins will be installed as Windows Service that is started automatically. Jenkins web interface by default can be accessed using http://localhost:8080/ and in order to log as administrator for the first time use admin as username and password can be found in the file initialAdminPassword on location: Jenkins_Instalation_Directory/secrets.

    Before we get started, we do need to do a little configuration. More precisely, we need to tell Jenkins about the build tools and JDK versions we will be using for our builds.

    Click on the Manage Jenkins link from the home page. This will take you to the Manage Jenkins page, the central one-stop-shop for all your Jenkins configuration. From this screen, you can configure your Jenkins server, install and upgrade plugins, keep track of system load, manage distributed build servers, and more.

    Figure 1. Manage Jenkins Screen

    For now, you will just need to configure the tools required to build our sample project. The application we will be building is a Java application. So in this case, all we need to do is to set up JDK path on the local machine where Jenkins is installed.Manage Jenkins->Global Tool Configuration->JDK

    Figure 2. Global Tool Configuration Screen

    Configuring Jenkins as Selenium Grid

    Selenium plugin for Jenkins, turns the Jenkins server into a Selenium Grid hub, making it easy to turn Jenkins Slaves into Selenium Grid Nodes.

    Step 1: Installation

    Search for “Selenium” on Jenkins “Manage Plugins” screen, select the plugin and click  “Install without restart”.

    Figure 6. Installing Selenium Plugin

    After installing the plugin, Selenium Grid link will appear on Jenkins Dashboard. Clicking on the link, will open Selenium Grid page. This screen gives an overview of the status of the Hub and links to the Grid consoles. Most importantly, it lists the commands how to initialize WebDriver  in your Selenium test code to utilize the Grid.

    Figure 7. Jenkins Selenium Grid

    As you can notice, under Registered Remote Controls, there is note that no nodes are registered , so further nodes should be registered to the Jenkins hub.

    Step 2: Creating a Node Configuration

    In order to create/register nodes, click on Configurations link from left-top menu. Since there is no registered nodes, on the displayed screen no nodes will be listed. Click New Configuration link in order to create new node configuration. On the displayed screen, at the bottom there is an option to create node configuration using JSON file. Actually, as a JSON configuration for the nodes in Jenkins, you can use same configurations as in Part I of this blog.

    Figure 8. Node Configuration

    After configuring Node2 on the same way and clicking on Nodes matching configurations  link from left-top menu, two registered nodes will be listed:

    Figure 9. Jenkins Grid with the two registered nodes

    Step 3: Launching the Nodes

    Once nodes are configured as per above steps, start the two instances of the Appium server and connect the mobile devices to your computer, as it was described in Part1. In our example it was used two mobile devices, so after navigating to Jenkins > Selenium Grid, on the Hub info screen you can notice that under Registered Remote Controls two nodes appears, that actually are the two connected mobile devices.

    Figure 10. Jenkins Selenium Grid with connected and registered mobile nodes

    Also if you navigate to Jenkins > Selenium Grid > Nodes matching configurations (Figure 9) and click on the master link, you will be able to control connected and registered mobile nodes. Actually, with this configuration are configured two slave Jenkins nodes, that also can be accessed via Jenkins > Manage Jenkins > Manage Nodes.

    Figure 11. Manage Jenkins Selenium Grid mobile nodes

     Conclusion

    In this blog as continuation for the first part, it was described how Jenkins can be configured as a Selenium Grid for mobile automated testing. Utilizing Jenkins in this manner can enable Continuous Testing on locally build mobile device farm as an option for public available mobile device farms.

    Jasmina Trombeva

    Technical Consultant