Skip to content

Commit 0a3d4a5

Browse files
authored
Update steps for running WinAppDriver autonomously
The steps in the current documentation leave ambiguity for the reader to figure out setup steps in a CI/CD kind of pipeline. Adding details around batch files and Task Schedulers to run winappdriver autonomously would help automation/testing teams to setup Winappdriver in a complementary style to the CI/CD flow. @timotiusmargo @hassanuz @licanhua @kat-y @DHowett - Kindly review and approve the PR as necessary .
1 parent a6f3d7b commit 0a3d4a5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Docs/RunningOnRemoteMachine.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,22 @@ capabilities.setCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App
2828
CalculatorSession = (WindowsDriver)(new WindowsDriver(new URL("http://10.X.X.52:4723/wd/hub"), capabilities));
2929
CalculatorSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
3030
CalculatorResult = CalculatorSession.findElementByAccessibilityId("CalculatorResults");
31-
```
31+
```
32+
5.WinAppDriver requires the Winappdriver server to be listening on the local host or IP address in order to perform the requisite UI interactions. While Appium generally takes care of this requirement on the local , for running on a server/remote machine, we need to perform a few extra steps as Winappdriver requires a GUI Output and the Winappdriver server running in an interactive shell.
33+
Therefore we need to follow the below steps on the remote machine for the Windows GUI tests to run in an autonomous fashion :
34+
- **5.1**. Setup Batch file to kill any old instances of WinAppDriver - This will be used in the KILLWAD scheduled task later
35+
- *Name* : kill_winappdriver.bat
36+
- *Contents* : taskkill /im WinAppDriver.exe /f
37+
- **5.2**. Setup Batch file to start WinAppdriver - This will be used in the StartWAD scheduled task later
38+
- *Name* : LaunchWAD.bat
39+
- *Contents* : cmd start /K "C:/Program Files (x86)/Windows Application Driver/WinAppDriver.exe" 10.x.xx.xx 4723/wd/hub
40+
- *Note*: The IP address above (10.x.xx.xx) should be replaced with the local IP address of the server/remote machine
41+
- **5.3**. Setup Batch file to logout (without disconnecting) from the remote machine :
42+
- *Name* : logout-rdp.bat
43+
- *Contents*: for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
44+
%windir%\System32\tscon.exe %%s /dest:console
45+
C:\Install\QRes.exe /x 1920 /y 1080
46+
)
47+
- *Note*: When using Remote Desktop to connect to a remote computer, closing Remote Desktop locks out the computer and displays the login screen. In the locked mode, the computer does not have GUI, so any currently running or scheduled GUI tests will fail.
48+
To avoid problems with GUI tests, we use the tscon utility to disconnect from Remote Desktop. tscon returns the control to the original local session on the remote computer, bypassing the logon screen. All programs on the remote computer continue running normally, including GUI tests. Therefore logout-rdp.bat should be exclusively used to logout from the remote machine and the admin user should not logout/disconnect manually from the remote . Also, the resolution is passed as a parameter in the above batch file as 1920x1080
49+
- **5.4** . Setup *Scheduled Tasks* on the target machine to kill Winappdriver (as per the BAT file in 5.1) and to start Winappdriver (as per the BAT file in 5.2) as the target programs. Ideally the Triggers should be *Daily* and *Startup* , so that the scripts running via the Test runner (Ex: JENKINS) , always have an instance of Winappdriver running on the server. These Scheduled Tasks should be setup to run with highest privileges on the machine (as Winappdriver requires to be run with Admin rights)

0 commit comments

Comments
 (0)