~~ 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. ** **
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 |
I built the environment on Windows10 32bit.
Settings ⇒ Update and Security ⇒ For Developers ⇒ Set in Developer Mode.
I have installed node-v8.11.1-x86.msi.
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)
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/
I got various errors such as inserting Python, but this command solved it. Convenient: hugging:
npm install --global --production windows-build-tools
Fee (・ д ・ ` *)
npm install -g appium
** 2018/09/13 postscript For Windows Application Driver only, Appium Client is not required. ** **
Only here I start the command prompt normally and work.
npm install wd
** 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.
Execute the following command.
java -jar selenium-server-standalone-3.11.0.jar -role hub
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 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.
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());
}
}
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.
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.
** 2018/09/13 postscript The following issues have been fixed in appium 1.9.0: hugging: **
Let's investigate by changing the output method of the log.
appium --nodeconfig NodeConfigAppium.json --log "C:/Users/XXXXX/Desktop/node/log.txt" --log-level "info" --log-timestamp --local-timezone
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
● 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.
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: **
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