Skip to content

Commit fa4c019

Browse files
authored
Merge pull request #72 from AutomateThePlanet/feature/webview-support
fix: fixed port issue with cdpRequest
2 parents 3bd5408 + e6542fb commit fa4c019

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ appWorkingDir | Optional working directory path for the application.
4848
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'}`
4949
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.
5050
isolatedScriptExecution | Whether PowerShell scripts are executed in an isolated session. Default is `false`.
51-
webviewDevtoolsPort | The local port number to use for devtools communication. By default the first free port from 10900..11000 range is selected. Consider setting the custom value if you are running parallel tests.
51+
enableWebView | Whether to enable WebView support. Set to true to allow switching into WebView contexts. Default is `false`.
52+
webviewDevtoolsPort | The local port number to use for devtools communication. By default the first free port from 10900..11000 range is selected. Set a custom port if running parallel tests or when app is "none"/"root"/appTopLevelWindow is specified.
5253

5354
Please note that more capabilities will be added as the development of this driver progresses. Since it is still in its early stages, some features may be missing or subject to change. If you need a specific capability or encounter any issues, please feel free to open an issue.
5455

lib/commands/contexts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,13 @@ export async function getWebViewDetails(this: NovaWindowsDriver, waitForWebviewM
171171
}
172172

173173
const host = 'localhost';
174-
const port = this.webviewDevtoolsPort;
174+
175+
if ((this.caps.app === 'none' || this.caps.app === 'root' || this.caps.appTopLevelWindow != null) && this.caps.webviewDevtoolsPort == null) {
176+
throw new errors.InvalidArgumentError(`Capability "webviewDevtoolsPort" must be set when using "none", "root", or "appTopLevelWindow" with "enableWebView"`);
177+
}
178+
179+
const port = this.webviewDevtoolsPort ??= this.caps.webviewDevtoolsPort ?? null;
180+
175181
const webViewDetails: WebViewDetails = {
176182
info: await cdpRequest.call(this, ({ host, port, endpoint: '/json/version', timeout: 10000 })),
177183
pages: await cdpRequest.call(this, ({ host, port, endpoint: '/json/list', timeout: 10000 })),

0 commit comments

Comments
 (0)