Skip to content

Commit 6f8d4b0

Browse files
committed
Reword significantly
1 parent 0a3a0f5 commit 6f8d4b0

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

Docs/RunningOnRemoteMachine.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,32 @@ CalculatorSession = (WindowsDriver)(new WindowsDriver(new URL("http://10.X.X.52:
2929
CalculatorSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
3030
CalculatorResult = CalculatorSession.findElementByAccessibilityId("CalculatorResults");
3131
```
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 (%windir%\System32\tscon.exe %%s /dest:console C:\Install\QRes.exe /x 1920 /y 1080)`
44-
- *Note*: Qres (http://qres.sourceforge.net/) is a remote vnc tool to change the resolution of the target machine to match the local machine
45-
- *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.
46-
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
47-
- **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)
48-
- **5.5** : Some remote machines or server instances can have a screen lock policy, preventing Winappdriver from interacting with GUI elements. This can be handled via either updating the policy or running a small script as follows :
49-
`Dim objResult
32+
33+
5. WinAppDriver requires the WinAppDriver server to be listening in order to perform the requisite UI interactions. While Appium generally takes care of this requirement on the local machine, running on a server/remote machine requires a few extra steps as WinAppDriver requires an interactive desktop session. Therefore, we recommend the following (community-contributed) setup steps on the remote machine:
34+
1. Setup a batch file to terminate any old instances of WinAppDriver
35+
- **Name**: `kill_winappdriver.cmd`
36+
- **Contents**: `taskkill /im WinAppDriver.exe /f`
37+
2. Setup a batch file to start WinAppDriver
38+
- **Name** : `LaunchWAD.cmd`
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 network IP address of the server.
41+
3. Setup a batch file to log off the remote session without disconnecting:
42+
- **Name** : `logout-rdp.cmd`
43+
- **Contents**: `for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (%windir%\System32\tscon.exe %%s /dest:console C:\Install\QRes.exe /x 1920 /y 1080)`
44+
- **Notes**
45+
- [Qres](http://qres.sourceforge.net/) is a remote VNC tool that can change the resolution of the target machine to match the local machine
46+
- When using Remote Desktop to connect to a remote computer, closing Remote Desktop locks out the computer and displays the login screen. While the machine is locked, the interactive session is paused. Any currently running or scheduled GUI tests will fail.
47+
- To avoid this, we use the `tscon` utility to disconnect from Remote Desktop. `tscon` returns 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. `logout-rdp.cmd` should be used exclusively to logout from the remote machine, and the admin user should not logout/disconnect manually. You may configure the resolution of the remote machine in the above batch file.
48+
4. Set up two *Scheduled Tasks* on the target machine to terminate WinAppDriver (script from step 5.1) and to start WinAppDriver (script from step 5.2) using the earlier scripts as the target programs.
49+
- Ideally, the Triggers should be *Daily* and *Startup* so that your Continuous Integration build agents will always have an instance of WinAppDriver running.
50+
- These Scheduled Tasks should be set up to run with highest privileges on the machine (as WinAppDriver requires Admin privileges.)
51+
5. Some remote machines or server instances can have a screen lock policy, preventing WinAppDriver from interacting with GUI elements. This can be handled via either updating the policy or by preventing sleep with this small VBScript snippet:
52+
53+
```vbscript
54+
Dim objResult
5055
Set objShell = WScript.CreateObject("WScript.Shell")
5156
Do While True
5257
objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
5358
Wscript.Sleep (6000)
54-
Loop`
59+
Loop
60+
```

0 commit comments

Comments
 (0)