Build a Windows application test environment with Selenium Grid, Appium, and Windows Application Driver

Introduction

~~ Manual test is never allowed ~~ I'm an uncle who promotes test automation: innocent: (I thought that the manual test is also good in this survey)

In charge "Do you want @umasaki to investigate the automatic test?" I "For the Web, go ahead and settle down!" In charge "There is also a Windows application" I "I can't do that yet: rolling_eyes:" Superior "I'm really looking forward to it!" I "I'll do it when this happens!"

So, when I heard about it, it seems that a lot of man-hours are taken for system testing even for Windows applications. I investigated to break through here.

**2018/09/13 Added unnecessary settings and problems. ** **

Software used

This is the software used for verification. I was really attracted to the software called SikuliX, but due to the unification of Selenium, it became the following software.

soft version Remarks
java 1.8.0_161
selenium-server-standalone.jar 3.11.0
Node.js 8.11.1
windows-build-tools 2.3.0 Install from npm
Appium 1.8.0 Install from npm
wd 1.6.2 Install from npm
WinAppDriver 1.0
Windows 10 SDK inspect.Use exe

Installation

I built the environment on Windows10 32bit.

Set Windows 10 to developer mode

Settings ⇒ Update and Security ⇒ For Developers ⇒ Set in Developer Mode. TESTSS.jpg

Node.js installation

I have installed node-v8.11.1-x86.msi.

Install Appium etc. with npm

When I proceeded with the content of "Experience Appium now with a simple installation" on the site, I stumbled upon installing Appium.

From here on, I started the command prompt with administrator privileges and worked. (I think)

Connection settings

I don't think the above four settings are necessary if you are not using a proxy. I haven't checked the meaning of the first command. Yes.

set HTTP_PROXY=http://proxyserver:8080
set HTTPS_PROXY=http://proxyserver:8080

npm config -g set proxy http://proxyserver:8080
npm config -g set https-proxy http://proxyserver:8080
npm config -g set registry http://registry.npmjs.org/

Avoid errors like Python or put it in

I got various errors such as inserting Python, but this command solved it. Convenient: hugging:

npm install --global --production windows-build-tools

Install Appium

Fee (・ д ・ ` *)

npm install -g appium

** 2018/09/13 postscript For Windows Application Driver only, Appium Client is not required. ** **

Install Appium Client

Install Appium Client

Only here I start the command prompt normally and work.

npm install wd

Install Windows Application Driver

** 2018/09/13 postscript I was able to install it with the following command. Internally it seems to be running WindowsApplicationDriver.msi, so you may have to run the command prompt with administrator privileges. ** **

npm install appium-windows-driver

I have installed WindowsApplicationDriver.msi.

Environment

Launch Selenium Grid Hub

Execute the following command.

java -jar selenium-server-standalone-3.11.0.jar -role hub

Launch Appium as Node

I haven't checked the meaning of the json configuration settings. There are some settings that seem annoying, but copy and paste.

NodeConfigAppium.json


{
  "capabilities":
      [
        {
          "platformName":"Windows",
          "deviceName":"WindowsPC",
          "maxInstances": 1
        }
      ],
  "configuration":
  {
    "cleanUpCycle":2000,
    "timeout":30000,
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "url":"(Node side)http://XXX.XXX.XXX.XXX:4723/wd/hub",
    "host": "(Node side)XXX.XXX.XXX.XXX",
    "port": (Node side)4723,
    "maxSession": 1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": (Hub side)4444,
    "hubHost": "(Hub side)XXX.XXX.XXX.XXX"
  }
}

After creating the configuration file, execute the following command.

appium --nodeconfig NodeConfigAppium.json

I will actually move it

I changed the sample a little and ran it. If you run it with this, if it is a Japanese OS, "Display is 8" will be displayed on the console.

Maven settings have been added to the environment of past articles, so they are as follows. If you think only about Appium, there are some things that you don't need. aWS050269.JPG

CalculatorTest.java


package test;

import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.AfterClass;Windows Application Driver
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.windows.WindowsDriver;

public class CalculatorTest {

    private static WindowsDriver<WebElement> CalculatorSession = null;
    private static WebElement CalculatorResult = null;

    @BeforeClass
    public static void setup() {
        try {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
            capabilities.setCapability("deviceName", "WindowsPC");
            capabilities.setCapability(CapabilityType.PLATFORM_NAME, "Windows");

            CalculatorSession = new WindowsDriver<WebElement>(new URL("http://XXX.XXX.XXX.XXX:4723/wd/hub"), capabilities);
            CalculatorSession.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

            CalculatorResult = CalculatorSession.findElementByAccessibilityId("CalculatorResults");

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        }
    }

    @AfterClass
    public static void TearDown() {
        CalculatorResult = null;
        if (CalculatorSession != null) {
            CalculatorSession.quit();
        }
        CalculatorSession = null;
    }

    @Test
    public void Addition() {
        CalculatorSession.findElementByAccessibilityId("num1Button").click();
        CalculatorSession.findElementByAccessibilityId("plusButton").click();
        CalculatorSession.findElementByAccessibilityId("num7Button").click();
        CalculatorSession.findElementByAccessibilityId("equalButton").click();
        System.out.println(CalculatorResult.getText());
    }
}

Examine the element

2018/07/20 postscript It is faster to check with WinApp Driver UI Recorder from the following.

Use inspect.exe, which is included when you install the Windows 10 SDK. In my environment it was in C: \ Program Files \ Windows Kits \ 10 \ bin \ 10.0.16299.0 \ x86 \ inspect.exe.

It's my style ... Start inspect.exe and uncheck Always on Top.

aWS050268 - コピー (2).JPG

I started the application I wanted to investigate (calculator in this case), moved the cursor for a while or clicked, and examined the AutomationId and reflected it in the source.

aWS050268 - コピー.JPG

Be in trouble

** 2018/09/13 postscript The following issues have been fixed in appium 1.9.0: hugging: **

If you specify an element that does not exist, an error will not occur in the specified time and wait 10 minutes or more

If you specify an element that does not exist, no error will occur in the specified time and wait for 10 minutes or more.

Let's investigate by changing the output method of the log.

Arguments when starting appium
appium --nodeconfig NodeConfigAppium.json --log "C:/Users/XXXXX/Desktop/node/log.txt" --log-level "info" --log-timestamp --local-timezone
Output log
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
● You should be getting the result element of the calculator
2018-05-02 14:33:07:512 - info: [HTTP] --> POST /wd/hub/session/4b9d3b16-2dd0-4e79-82f8-ce5694e514c6/element
2018-05-02 14:33:07:512 - info: [HTTP] {"using":"accessibility id","value":"CalculatorResults"}
2018-05-02 14:33:07:512 - info: [W3C] Driver proxy active, passing request on via HTTP proxy
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] ==========================================
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] POST /wd/hub/session/6DF966FD-DB90-4ECC-B490-552323C225FF/element HTTP/1.1
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] Accept: */*
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] Connection: keep-alive
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] Content-Length: 56
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] Content-Type: application/json
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] User-Agent: appium
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:07:590 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:07:622 - info: [WinAppDriver] [STDOUT] HTTP/1.1 200 OK
2018-05-02 14:33:07:622 - info: [WinAppDriver] [STDOUT] Content-Length: 100
2018-05-02 14:33:07:622 - info: [WinAppDriver] [STDOUT] Content-Type: application/json
2018-05-02 14:33:07:622 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:07:622 - info: [WinAppDriver] [STDOUT] {"sessionId":"6DF966FD-DB90-4ECC-B490-552323C225FF","status":0,"value":{"ELEMENT":"42.3540260.3.5"}}
2018-05-02 14:33:07:622 - info: [JSONWP Proxy] Replacing sessionId 6DF966FD-DB90-4ECC-B490-552323C225FF with 4b9d3b16-2dd0-4e79-82f8-ce5694e514c6
2018-05-02 14:33:07:622 - info: [HTTP] <-- POST /wd/hub/session/4b9d3b16-2dd0-4e79-82f8-ce5694e514c6/element 200 117 ms - 100
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
● You should be getting an element that does not exist
2018-05-02 14:33:32:841 - info: [HTTP] --> POST /wd/hub/session/4b9d3b16-2dd0-4e79-82f8-ce5694e514c6/element
2018-05-02 14:33:32:841 - info: [HTTP] {"using":"accessibility id","value":"num1Buttonabc"}
2018-05-02 14:33:32:841 - info: [W3C] Driver proxy active, passing request on via HTTP proxy
2018-05-02 14:33:33:044 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:33:044 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:33:044 - info: [WinAppDriver] [STDOUT] ==========================================
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] POST /wd/hub/session/6DF966FD-DB90-4ECC-B490-552323C225FF/element HTTP/1.1
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] Accept: */*
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] Connection: keep-alive
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] Content-Length: 52
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] Content-Type: application/json
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] User-Agent: appium
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:33:059 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:45:825 - info: [WinAppDriver] [STDOUT] HTTP/1.1 404 Not Found
2018-05-02 14:33:45:841 - info: [WinAppDriver] [STDOUT] Content-Length: 139
2018-05-02 14:33:45:841 - info: [WinAppDriver] [STDOUT] Content-Type: application/json
2018-05-02 14:33:45:841 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:33:45:841 - info: [WinAppDriver] [STDOUT] {"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}
↑↑↑ It takes 10 minutes to return POST ↓↓↓
2018-05-02 14:43:32:858 - info: [HTTP] <-- POST /wd/hub/session/4b9d3b16-2dd0-4e79-82f8-ce5694e514c6/element - - ms - -
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
2018-05-02 14:47:20:139 - info: [HTTP] --> DELETE /wd/hub/session/4b9d3b16-2dd0-4e79-82f8-ce5694e514c6
2018-05-02 14:47:20:139 - info: [HTTP] {}
2018-05-02 14:47:20:139 - info: [Appium] Removing session 4b9d3b16-2dd0-4e79-82f8-ce5694e514c6 from our master session list
2018-05-02 14:47:20:171 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:47:20:171 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:47:20:171 - info: [WinAppDriver] [STDOUT] ==========================================
2018-05-02 14:47:20:171 - info: [WinAppDriver] [STDOUT] DELETE /wd/hub/session/6DF966FD-DB90-4ECC-B490-552323C225FF HTTP/1.1
2018-05-02 14:47:20:171 - info: [WinAppDriver] [STDOUT] Accept: */*
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] Connection: keep-alive
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] Content-Length: 0
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] Content-Type: application/json
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] User-Agent: appium
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:47:20:186 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:47:20:218 - info: [WinAppDriver] [STDOUT] HTTP/1.1 200 OK
2018-05-02 14:47:20:218 - info: [WinAppDriver] [STDOUT] Content-Length: 63
2018-05-02 14:47:20:233 - info: [WinAppDriver] [STDOUT] Content-Type: application/json
2018-05-02 14:47:20:233 - info: [WinAppDriver] [STDOUT] 
2018-05-02 14:47:20:233 - info: [WinAppDriver] [STDOUT] {"sessionId":"6DF966FD-DB90-4ECC-B490-552323C225FF","status":0}
2018-05-02 14:47:20:233 - warn: [WinAppDriver] Did not get confirmation WinAppDriver deleteSession worked; Error was: Error: Did not get a valid response object. Object was: {"sessionId":"6DF966FD-DB90-4ECC-B490-552323C225FF","status":0}
2018-05-02 14:47:20:514 - info: [HTTP] <-- DELETE /wd/hub/session/4b9d3b16-2dd0-4e79-82f8-ce5694e514c6 200 295 ms - 76
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓

It takes 10 minutes to post after getting the non-existent element with WinAppDriver and issuing 404 ... To isolate the Appium problem (setting?), Launch the Windows Application Driver directly and check.

Arguments when starting WinAppDriver

Adjusted with arguments so that it can be executed without changing the source. I saw somewhere that I had to run it with administrator privileges.

"C:\Program Files\Windows Application Driver\WinAppDriver.exe" XXX.XXX.XXX.XXX 4723/wd/hub

Result ... ** It's over soon! ** ** The error also comes back properly with NoSuchElementException, If you can't solve it via Appium, you should start WinAppDriver directly.

** 2018/09/13 postscript And I'm doing various things and new troubles ...: weary: **

If multiple apps are started from Windows Application Driver (WinAppDriver.exe) on one machine, all the apps running with quit will be disconnected.

WinAppDriver.exe is called via Appium, but the process of WinAppDriver.exe is one even for multiple apps, and when quit is called, it seems that the exe is gone.

If you start WinAppDriver.exe directly, the WinAppDriver.exe process will not disappear even if you quit. (I wonder if that is the case) So it works fine.

If it is close, even if the process remains, the driver will be treated as not released by Selenium Grid, so you have to wait until it times out.

I decided to limit the number of Sessions that can be started on one machine to one unless there is some action such as starting WinAppDriver.exe in multiple processes in Appium.

Recommended Posts

Build a Windows application test environment with Selenium Grid, Appium, and Windows Application Driver
Build an E2E test environment with Selenium (Java)
Build a web application development environment that uses Java, MySQL, and Redis with Docker CE for Windows
Ruby ① Build a Windows environment
Build a Node-RED environment with Docker to move and understand
Build a Node.js environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build a web application with Javalin
Build a PureScript development environment with Docker
Build and manage RStudio environment with Docker-compose
Build a Wordpress development environment with Docker
I tried to build a Firebase application development environment with Docker in 2020
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
Build a bulletin board API with authentication and authorization with Rails 6 # 1 Environment construction
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Build a Laravel / Docker environment with VSCode devcontainer
Build a WordPress development environment quickly with Docker
Build and test Java + Gradle applications with Wercker
[Win10] Build a JSF development environment with NetBeans
Prepare a scraping environment with Docker and Java
Build a Java development environment with VS Code
Install Ubuntu 20.04 in virtual box on windows10 and build a development environment using docker
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Easily build a Vue.js environment with Docker + Vue CLI
Build ruby debug environment with VS Code of Windows 10
[Note] Build a Python3 environment with Docker in EC2
[Environment construction] Build a Java development environment with VS Code!
Build WordPress environment with Docker (Local) and AWS (Production)
Build a local development environment for Rails tutorials with Docker-Introduce Bootstrap and Font Awesome with Webpack-
Deploying a Java environment with Windows Subsystem for Linux (WSL)
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
Build a CentOS 8 virtual environment on your Mac with VirtualBox
Build a bulletin board API with authentication authorization in Rails 6 # 11 User model test and validation added
How to build an environment with Docker, which is the minimum required to start a Rails application
Build docker environment with WSL
Build a data processing environment with Google Cloud DataFlow + Pub / Sub
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Build a development environment where Ruby on Rails breakpoints work on Windows
Create a flyway jar with maven and docker build (migrate) with docker-maven-plugin
Build a browser test environment using Capybara in the Docker development environment
Building a haskell environment with Docker + VS Code on Windows 10 Home
Look through Java and MySQL PATH with environment variables [Windows version]
Install Rails in the development environment and create a new application
Build a development environment for Django + MySQL + nginx with Docker Compose
Creating a dual boot environment for Ubuntu Server 20.04.1 LTS and Windows 10
Steps to build a Ruby on Rails development environment with Vagrant
I tried to make a machine learning application with Dash (+ Docker) part1 ~ Environment construction and operation check ~
# 1 [Beginner] Create a web application (website) with Eclipse from knowledge 0. "Let's build an environment for creating web applications"