Skip to content

Commit

Permalink
feat: Allow specifying the /forcequit argument for WAD (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
papauorg authored Nov 15, 2024
1 parent dba67a9 commit a9dda08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ appium:appWorkingDir | Full path to the folder, which is going to be set as the
appium:createSessionTimeout | Timeout in milliseconds used to retry Appium Windows Driver session startup. This capability could be used as a workaround for the long startup times of UWP applications (aka `Failed to locate opened application window with appId: TestCompany.my_app4!App, and processId: 8480`). Default value is `20000`.
ms:waitForAppLaunch | Similar to `createSessionTimeout`, but in seconds and is applied on the server side. Enables Appium Windows Driver to wait for a defined amount of time after an app launch is initiated prior to attaching to the application session. The limit for this is 50 seconds.
ms:experimental-webdriver | Enables experimental features and optimizations. See Appium Windows Driver release notes for more details on this capability. `false` by default.
ms:forcequit | Defines if the WinAppDriver should be started with the `/forcequit` command line argument which will forcefully kill the application process during session termination. Default `false`.
appium:systemPort | The port number to execute Appium Windows Driver server listener on, for example `5556`. The port must not be occupied. The default starting port number for a new Appium Windows Driver session is `4724`. If this port is already busy then the next free port will be automatically selected.
appium:prerun | An object containing either `script` or `command` key. The value of each key must be a valid PowerShell script or command to be executed prior to the WinAppDriver session startup. See [Power Shell commands execution](#power-shell-commands-execution) for more details. Example: `{script: 'Get-Process outlook -ErrorAction SilentlyContinue'}`
appium:postrun | An object containing either `script` or `command` key. The value of each key must be a valid PowerShell script or command to be executed after WinAppDriver session is stopped. See [Power Shell commands execution](#power-shell-commands-execution) for more details.
Expand Down
3 changes: 3 additions & 0 deletions lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ const desiredCapConstraints = /** @type {const} */ ({
'ms:waitForAppLaunch': {
isNumber: true // in seconds
},
'ms:forcequit': {
isBoolean: true
},
'ms:experimental-webdriver': {
isBoolean: true
},
Expand Down
8 changes: 8 additions & 0 deletions lib/winappdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class WADProcess {
this.port = opts.port;
this.executablePath = opts.executablePath;
this.proc = null;
this.isForceQuitEnabled = opts.isForceQuitEnabled;
}

get isRunning () {
Expand All @@ -69,6 +70,11 @@ class WADProcess {
}

const args = [`${this.port}${this.base}`];

if (this.isForceQuitEnabled) {
args.push('/forcequit');
}

this.proc = new SubProcess(this.executablePath, args, {
encoding: 'ucs2'
});
Expand Down Expand Up @@ -120,12 +126,14 @@ class WinAppDriver {

async start (caps) {
const executablePath = await getWADExecutablePath();
const isForceQuitEnabled = caps['ms:forcequit'] === true;

this.process = new WADProcess(this.log, {
// XXXYD TODO: would be better if WinAppDriver didn't require passing in /wd/hub as a param
base: DEFAULT_BASE_PATH,
port: this.proxyPort,
executablePath,
isForceQuitEnabled
});
await this.process.start();

Expand Down

0 comments on commit a9dda08

Please sign in to comment.