### Install Appium NovaWindows Driver Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/README.md Install the driver using npm or the Appium CLI. This is the first step before using the driver. ```bash # Via npm appium driver install --source=npm appium-novawindows-driver # Or with Appium CLI appium driver install appium-novawindows-driver ``` -------------------------------- ### Start Screen Recording Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md Starts recording the desktop screen using FFmpeg. The driver uses bundled FFmpeg, and no system PATH fallback exists. ```typescript await driver.executeScript('windows: startRecordingScreen', [{ fps: 30, timeLimit: 120, captureCursor: true }]); ``` -------------------------------- ### Install Project Dependencies and Run Build Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Installs project dependencies using npm and then transpiles TypeScript files to build the project. Linting is also available to check code quality. ```bash npm install npm run lint npm run build ``` -------------------------------- ### Install NovaWindows Driver Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Use this command to install the NovaWindows Driver for Appium 2/3. Ensure you have Appium 2 or 3 installed. ```bash appium driver install --source=npm appium-novawindows-driver ``` -------------------------------- ### windows: startRecordingScreen Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Starts screen recording using the bundled ffmpeg. ```APIDOC ## windows: startRecordingScreen ### Description Starts screen recording using the **bundled ffmpeg** included with the driver. There is no system PATH fallback: if the bundle is not present (e.g. driver was not installed via npm with dependencies), screen recording is not available and the driver reports a clear error. ``` -------------------------------- ### Complete Appium NovaWindows Driver Configuration Example Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Demonstrates how to create a session with the Appium NovaWindows driver using a full set of options, including application, interaction, WebView, and lifecycle configurations. ```python from appium import webdriver from appium.options.windows import WindowsOptions # Create options with full configuration options = WindowsOptions() # Required options.platform_name = 'Windows' options.automation_name = 'NovaWindows' # Application options.app = 'C:\\Windows\\System32\\notepad.exe' options.app_arguments = '/edit "C:\\test.txt"' options.app_working_dir = 'C:\\Documents' options.should_close_app = True # Interaction options.delay_before_click = 50 options.delay_after_click = 50 options.smooth_pointer_move = 'ease-in-out' # WebView (if needed) options.webview_enabled = True options.webview_devtools_port = 10900 options.chromedriver_executable_path = 'C:\\drivers\\chromedriver.exe' # Lifecycle options.ms_wait_for_app_launch = 5000 options.ms_forcequit = False # Setup/cleanup options.prerun = {'script': 'Write-Output "Session starting"'} options.postrun = {'script': 'Write-Output "Session ended"'} # Create session driver = webdriver.Remote('http://localhost:4723', options=options) try: # Run tests pass finally: driver.quit() ``` -------------------------------- ### Screen Recording Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md Commands for starting and stopping screen recording. ```APIDOC ## windows: startRecordingScreen ### Description Starts recording the desktop screen using FFmpeg. The driver uses bundled FFmpeg; no system PATH fallback exists. ### Method `executeScript` ### Endpoint `windows: startRecordingScreen` ### Parameters #### Request Body - **fps** (number) - Optional - Frames per second (default: 15). - **timeLimit** (number) - Optional - Max duration in seconds (default: 600). - **preset** (string) - Optional - FFmpeg preset: 'ultrafast', 'veryfast', etc. - **captureCursor** (boolean) - Optional - Include cursor in recording. - **captureClicks** (boolean) - Optional - Highlight clicks. - **audioInput** (string) - Optional - Audio device name. - **videoFilter** (string) - Optional - FFmpeg filter string. ### Request Example ```typescript await driver.executeScript('windows: startRecordingScreen', [{ fps: 30, timeLimit: 120, captureCursor: true }]); ``` ``` ```APIDOC ## windows: stopRecordingScreen ### Description Stops screen recording and returns the video. ### Method `executeScript` ### Endpoint `windows: stopRecordingScreen` ### Parameters #### Request Body - **remotePath** (string) - Optional - Remote upload URL. - **user** (string) - Optional - Upload credentials. - **pass** (string) - Optional - Upload credentials. - **method** (string) - Optional - HTTP method ('PUT' default). - **headers** (Record) - Optional - Request headers. - **fileFieldName** (string) - Optional - Multipart field name. - **formFields** (Array<[string, string]> | Record) - Optional - Additional form fields. ### Returns `string` - Base64-encoded MP4 video (or empty if uploaded to `remotePath`). ### Request Example ```typescript // Get video as base64 const videoB64 = await driver.executeScript('windows: stopRecordingScreen', [{}]); fs.writeFileSync('recording.mp4', videoB64, 'base64'); // Upload to remote server await driver.executeScript('windows: stopRecordingScreen', [{ remotePath: 'https://example.com/upload', user: 'username', pass: 'password' }]); ``` ``` -------------------------------- ### Automating WebView with NovaWindows Driver Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/context-commands.md This example demonstrates how to enable and interact with WebView contexts using the NovaWindows driver. It shows switching between native and web contexts, interacting with elements in both, and managing the driver session. ```typescript const options = new WindowsOptions(); options.app = 'C:\\WebViewApp\\app.exe'; options.automation_name = 'NovaWindows'; options.webview_enabled = true; const driver = await webdriver.Remote( 'http://localhost:4723', options ); try { // Start in native context let contexts = await driver.getContexts(); console.log('Available contexts:', contexts); // Output: ['NATIVE_APP', 'WEBVIEW_page-1'] // Interact with native UI const nativeButton = await driver.findElement('accessibility id', 'NativeButton'); await driver.click(nativeButton); // Get WebView context const webviewContext = contexts.find(c => c.startsWith('WEBVIEW_')); // Switch to WebView await driver.setContext(webviewContext); console.log('Switched to', await driver.getCurrentContext()); // Now interact with web content const webElement = await driver.findElement('css selector', 'input[id="search"]'); await driver.setValue(webElement, 'search term'); // Switch back to native await driver.setContext('NATIVE_APP'); const result = await driver.getText(nativeButton); console.log('Native button text:', result); } finally { await driver.quit(); } ``` -------------------------------- ### Minimal Python Example for Appium NovaWindows Driver Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/README.md A basic Python script demonstrating how to launch Notepad, interact with its text box, and retrieve page source and screenshots. Ensure Appium server is running on http://localhost:4723. ```python from appium import webdriver from appium.options.windows import WindowsOptions # Create options options = WindowsOptions() options.platform_name = 'Windows' options.automation_name = 'NovaWindows' options.app = 'C:\\Windows\\System32\\notepad.exe' # Create session driver = webdriver.Remote('http://localhost:4723', options=options) try: # Find and interact with elements text_box = driver.find_element('class name', 'Edit') driver.execute_script('windows: setValue', [text_box, 'Hello World']) # Get information page_source = driver.page_source screenshot = driver.get_screenshot_as_base64() finally: driver.quit() ``` -------------------------------- ### Appium NovaWindowsDriver Error Handling Examples Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/README.md Demonstrates how to handle common Appium errors such as NoSuchElementError, InvalidElementStateError, and UnknownError using Python's try-except blocks. These examples are useful for robustly interacting with Windows applications. ```python from appium.common.errors import ( NoSuchElementError, InvalidElementStateError, UnknownError, TimeoutError ) try: element = driver.find_element('accessibility id', 'NotFound') except NoSuchElementError: print('Element not found - verify accessibility ID') try: driver.click(element) except InvalidElementStateError: print('Element not in valid state - may be disabled or off-screen') try: driver.set_context('WEBVIEW_unknown') except UnknownError: print('WebView context does not exist') ``` -------------------------------- ### Create WebDriver Session with NovaWindows Driver Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Example of creating a WebDriver session using the NovaWindows driver in Python. This snippet demonstrates setting platform name, automation name, and the application path. ```python from appium import webdriver from appium.options.windows import WindowsOptions options = WindowsOptions() options.platform_name = 'Windows' options.automation_name = 'NovaWindows' options.app = 'C:\\Windows\\System32\\notepad.exe' driver = webdriver.Remote('http://localhost:4723', options=options) ``` -------------------------------- ### Executing Extension Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md All extension commands are invoked using the `executeScript()` method. Examples are provided for TypeScript/Node.js, Python, and Java. ```typescript const result = await driver.executeScript('windows: ', [args]); ``` ```python result = driver.execute_script('windows: ', args) ``` ```java Object result = driver.executeScript("windows: ", args); ``` -------------------------------- ### Get and Set Contexts Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/context-commands.md Retrieve all available contexts and switch between them. This is useful for applications that have multiple WebView instances or a mix of native and web content. ```APIDOC ## Get Contexts ### Description Retrieves a list of all available contexts within the application. ### Method `driver.getContexts()` ### Endpoint Not applicable (SDK method) ### Response #### Success Response - **contexts** (Array) - A list of context identifiers (e.g., 'NATIVE_APP', 'WEBVIEW_1', 'WEBVIEW_2'). ### Response Example ```json ["NATIVE_APP", "WEBVIEW_1", "WEBVIEW_2"] ``` ## Set Context ### Description Switches the driver's focus to a specific context. This is essential for interacting with elements within a particular WebView or returning to the native application. ### Method `driver.setContext(contextId: string)` ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **contextId** (string) - Required - The identifier of the context to switch to (e.g., 'NATIVE_APP', 'WEBVIEW_1'). ### Request Example ```typescript await driver.setContext('WEBVIEW_1'); ``` ### Response #### Success Response No explicit return value on success. #### Response Example ```json null ``` ### Error Handling - **InvalidArgumentError**: Thrown if the specified `contextId` is not found or if the browser type is unsupported. - **Driver Connection Issues**: May occur if the ChromeDriver/EdgeDriver version mismatches the WebView version. ``` -------------------------------- ### Create WebDriver Session with NovaWindows Driver (TypeScript) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Example of creating a WebDriver session using the NovaWindows driver in TypeScript/Node.js. This snippet shows how to configure capabilities for platform, automation name, and application. ```typescript import { remote } from 'webdriverio' const driver = await remote({ hostname: 'localhost', port: 4723, logLevel: 'trace', path: '/wd/hub', capabilities: { platformName: 'Windows', 'appium:automationName': 'NovaWindows', 'appium:app': 'C:\\Windows\\System32\\notepad.exe' } }) ``` -------------------------------- ### Execute PowerShell to Get Windows Version Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Fetch the Windows operating system version information by executing a PowerShell command. ```typescript // Get Windows version const osVersion = await driver.executeScript('powerShell', '[System.Environment]::OSVersion'); ``` -------------------------------- ### Clipboard Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md Commands for interacting with the Windows clipboard, allowing you to set and get content. ```APIDOC ## windows: setClipboard ### Description Sets Windows clipboard content. ### Method executeScript ### Endpoint windows: setClipboard ### Parameters #### Arguments Object - **b64Content** (string) - Required - Base64-encoded content - **contentType** (string) - Optional - Content type ('plaintext' or 'image', default: 'plaintext') ### Request Example ```typescript // Set text const textB64 = Buffer.from('Hello Clipboard').toString('base64'); await driver.executeScript('windows: setClipboard', [{ b64Content: textB64, contentType: 'plaintext' }]); // Set image (PNG) const imageB64 = fs.readFileSync('image.png').toString('base64'); await driver.executeScript('windows: setClipboard', [{ b64Content: imageB64, contentType: 'image' }]); ``` ``` ```APIDOC ## windows: getClipboard ### Description Retrieves Windows clipboard content. ### Method executeScript ### Endpoint windows: getClipboard ### Parameters #### Arguments Object - **contentType** (string) - Optional - Content type to retrieve ('plaintext' or 'image') ### Returns `string` - Base64-encoded clipboard content ### Response Example ```typescript // Get text const textB64 = await driver.executeScript('windows: getClipboard', [{ contentType: 'plaintext' }]); const text = Buffer.from(textB64, 'base64').toString('utf-8'); // Get image const imageB64 = await driver.executeScript('windows: getClipboard', [{ contentType: 'image' }]); ``` ``` -------------------------------- ### Configure Pre-run PowerShell Script Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Use the `prerun` option to specify a PowerShell script or command to execute before the session starts. This requires the `--allow-insecure=power_shell` Appium flag. ```python options.prerun = { 'script': 'Get-Process explorer | Select-Object -First 1' } ``` ```python # Or using command key (equivalent) options.prerun = { 'command': '[System.Diagnostics.Process]::Start("notepad.exe")' } ``` -------------------------------- ### Execute PowerShell to Get Process Information Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Use this snippet to retrieve details about a running process, such as 'notepad', by executing a PowerShell command through the driver. ```typescript // Get process information const proc = await driver.executeScript('powerShell', 'Get-Process -Name notepad | Select-Object Id, ProcessName, Handles'); ``` -------------------------------- ### Get All Display Information with PowerShell Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Use this script to retrieve comprehensive display metrics such as device name, resolution, and primary display status. This is useful when the basic getOrientation() method is insufficient. ```typescript const displays = await driver.executeScript('powerShell', " Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Screen]::AllScreens | Select-Object -Property @{ Label='Name'; Expression={$_.DeviceName} }, @{ Label='Resolution'; Expression={$_.Bounds.Width + 'x' + $_.Bounds.Height} }, IsPrimary "); ``` -------------------------------- ### Get Clipboard Content with NovaWindows Driver Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Retrieves content from the Windows clipboard. Can fetch either plain text or a base64-encoded PNG image. ```json { "contentType": "image" } ``` -------------------------------- ### Internal PowerShell Session Initialization Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/powershell-commands.md This TypeScript code demonstrates the internal process of starting a PowerShell session. It's called automatically by the driver during session creation when specific capabilities are set. ```typescript // This is called automatically by the driver await driver.startPowerShellSession(); // The session is now ready for commands const source = await driver.getPageSource(); ``` -------------------------------- ### Get Screenshot Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/app-and-window-commands.md Captures a screenshot of the current window or desktop as a base64-encoded PNG. If no application is set, it captures the full desktop. The screenshot is automatically focused on the app window before capture if possible. ```typescript const screenshot = await driver.getScreenshot(); fs.writeFileSync('screenshot.png', screenshot, 'base64'); ``` -------------------------------- ### Get Device Time (Custom Format) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Retrieves the current system date and time from the Windows machine using a custom .NET datetime format string. This example shows how to get the date only. ```typescript const dateOnly = await driver.getDeviceTime(undefined, 'yyyy-MM-dd'); console.log(dateOnly); // "2025-06-27" ``` -------------------------------- ### Get Device Time for Test Execution Stamping Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Retrieve the current device time formatted for logging test execution start and end times. Ensure the driver is initialized before use. ```typescript const startTime = await driver.getDeviceTime(undefined, 'yyyy-MM-dd HH:mm:ss.fff'); // Perform test operations const endTime = await driver.getDeviceTime(undefined, 'yyyy-MM-dd HH:mm:ss.fff'); console.log(`Test execution: ${startTime} to ${endTime}`); ``` -------------------------------- ### Execute PowerShell to Get System Memory Information Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md This snippet demonstrates how to fetch system memory details, including total and free physical memory, by running a PowerShell command. ```typescript // Get system memory const memInfo = await driver.executeScript('powerShell', 'Get-WmiObject Win32_OperatingSystem | Select-Object TotalVisibleMemorySize, FreePhysicalMemory'); ``` -------------------------------- ### Get Device Time (Long Format) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Retrieves the current system date and time from the Windows machine using a custom .NET datetime format string. This example demonstrates a long date and time format. ```typescript const longFormat = await driver.getDeviceTime(undefined, 'dddd, MMMM dd, yyyy hh:mm tt'); console.log(longFormat); // "Friday, June 27, 2025 02:30 PM" ``` -------------------------------- ### Get Window Handles Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/app-and-window-commands.md Gets native window handles for all top-level windows, returned as an array of hexadecimal strings. ```typescript const handles = await driver.getWindowHandles(); handles.forEach(h => console.log(h)); ``` -------------------------------- ### Get Device Time (ISO 8601) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Retrieves the current system date and time from the Windows machine in ISO 8601 format. This is the default format when no format string is provided. ```typescript const time = await driver.getDeviceTime(); console.log(time); // "2025-06-27T14:30:45-07:00" ``` -------------------------------- ### Get Window Handle Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/app-and-window-commands.md Gets the native window handle of the current root element, returned as a hexadecimal string. ```typescript const handle = await driver.getWindowHandle(); console.log(handle); // "0x000C15A0" ``` -------------------------------- ### Launch and Manage Apps Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/INDEX.md Configure application launch options, including the executable path and arguments, either during session initialization or by changing the root element and setting the window during the session. ```typescript // Specified in capabilities options.app = 'C:\\app.exe'; options.app_arguments = '/edit file.txt'; // Or change during session await driver.changeRootElement('C:\\app.exe'); await driver.setWindow('0x000C15A0'); ``` -------------------------------- ### Get Window Rectangle Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/app-and-window-commands.md Gets the bounding rectangle of the current window, returning an object with x, y, width, and height properties. ```typescript const rect = await driver.getWindowRect(); console.log(`Window: x=${rect.x}, y=${rect.y}, width=${rect.width}, height=${rect.height}`); ``` -------------------------------- ### Configure for Desktop Automation Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Sets the 'app' capability to 'root' to enable desktop automation without launching a specific application. The root element will be the desktop itself. ```python options.app = 'root' ``` -------------------------------- ### Get Display Orientation Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Gets the current display orientation of the screen. This is a synchronous method and returns either 'PORTRAIT' or 'LANDSCAPE'. ```typescript const orientation = driver.getOrientation(); if (orientation === 'LANDSCAPE') { console.log('Screen is in landscape mode'); } ``` -------------------------------- ### Complex Action Example: Drag and Drop with Keyboard Modifier Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/action-commands.md Demonstrates combining key and pointer actions to perform a drag-and-drop operation while holding a keyboard modifier (Shift). Ensure the 'keyboard' and 'mouse' action IDs are correctly referenced. ```typescript const element = await driver.findElement('accessibility id', 'draggable'); const dropZone = await driver.findElement('accessibility id', 'dropzone'); // Drag and drop with keyboard modifier await driver.performActions([ // Start holding Shift { type: 'key', id: 'keyboard', actions: [ {type: 'keyDown', value: ''} // Shift ] }, // Pointer sequence: move to element, drag to drop zone { type: 'pointer', id: 'mouse', parameters: {pointerType: 'mouse'}, actions: [ {type: 'pointerMove', origin: element}, {type: 'pointerDown', button: 0}, {type: 'pointerMove', origin: dropZone, duration: 1000}, {type: 'pointerUp', button: 0} ] }, // Release Shift { type: 'key', id: 'keyboard', actions: [ {type: 'keyUp', value: ''} ] } ]); ``` -------------------------------- ### Launch a Desktop Application Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Configures the driver to launch a specific desktop application by its absolute path. Ensure the path is correctly specified. ```python options.app = 'C:\\Windows\\System32\\notepad.exe' ``` -------------------------------- ### Execute Pre-run and Post-run PowerShell Scripts Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/powershell-commands.md Configure scripts to run before session startup or after session shutdown using the `prerun` and `postrun` options. Both `script` and `command` keys are equivalent for executing script text. ```python options = WindowsOptions() options.prerun = { 'script': 'Get-Process explorer | Select-Object -First 1' } options.postrun = { 'command': 'Remove-Item -Path C:\temp\appium-test.txt -Force' } driver = webdriver.Remote('http://localhost:4723', options=options) ``` -------------------------------- ### Get Element Text Content Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/element-commands.md Retrieves the visible text content of a UI element. This is commonly used to get the text displayed on buttons, labels, or other text-based controls. ```typescript const buttonText = await driver.getText(buttonElementId); ``` -------------------------------- ### Perform Hover Gesture Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md Simulates hovering a mouse cursor from a start position to an end position. Supports specifying start and end elements or coordinates, and modifier keys. ```typescript await driver.executeScript('windows: hover', [{ startElementId: sourceId, endElementId: targetId, durationMs: 500 }]); ``` -------------------------------- ### Initialize Appium Windows Driver with PyTest Fixture Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Sets up Appium Windows Driver instances for UWP, classic Windows apps, and existing windows using PyTest fixtures. Ensure the Appium server is running and accessible. ```python import pytest from appium import webdriver from appium.options.windows import WindowsOptions def generate_options(): uwp_options = WindowsOptions() # How to get the app ID for Universal Windows Apps (UWP): # https://www.securitylearningacademy.com/mod/book/view.php?id=13829&chapterid=678 uwp_options.app = 'Microsoft.WindowsCalculator_8wekyb3d8bbwe!App' uwp_options.automation_name = 'NovaWindows' classic_options = WindowsOptions() classic_options.app = 'C:\\Windows\\System32\\notepad.exe' classic_options.automation_name = 'NovaWindows' use_existing_app_options = WindowsOptions() # Active window handles could be retrieved from any compatible UI inspector app: # https://docs.microsoft.com/en-us/windows/win32/winauto/inspect-objects # or https://accessibilityinsights.io/. # Also, it is possible to use the corresponding WinApi calls for this purpose: # https://referencesource.microsoft.com/#System/services/monitoring/system/diagnosticts/ProcessManager.cs,db7ac68b7cb40db1 # # This capability could be used to create a workaround for UWP apps startup: # https://github.com/microsoft/WinAppDriver/blob/master/Samples/C%23/StickyNotesTest/StickyNotesSession.cs use_existing_app_options.app_top_level_window = hex(12345) use_existing_app_options.automation_name = 'NovaWindows' return [uwp_options, classic_options, use_existing_app_options] @pytest.fixture(params=generate_options()) def driver(request): drv = webdriver.Remote('http://127.0.0.1:4723', options=request.param) yield drv drv.quit() def test_app_source_could_be_retrieved(driver): assert len(driver.page_source) > 0 ``` -------------------------------- ### getContexts Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/context-commands.md Lists all available automation contexts, including native and any detected WebViews. ```APIDOC ## getContexts(): Promise ### Description Lists all available automation contexts. ### Returns - `Promise` - Array of context IDs ### Returns - Always includes `'NATIVE_APP'` as first element - Additional `'WEBVIEW_'` contexts for each detected WebView page ### Example ```typescript const contexts = await driver.getContexts(); console.log(contexts); // ['NATIVE_APP', 'WEBVIEW_page-1', 'WEBVIEW_page-2'] ``` ``` -------------------------------- ### windows: clickAndDrag Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Performs a click-and-drag action. It moves to the start position, presses the mouse button, moves to the end position over a specified duration, and then releases the button. Start and end points can be defined by element IDs or screen coordinates. ```APIDOC ## windows: clickAndDrag ### Description Performs a click-and-drag: move to the start position, press the mouse button, move to the end position over the given duration, then release. Start and end can be specified by element (center or offset) or by screen coordinates. Uses the same Windows input APIs as other pointer actions. ### Parameters #### Path Parameters - **startElementId** (string) - Optional - Element ID for drag start. Use *or* startX/startY. - **startX** (number) - Optional - X coordinate for drag start (with startY). - **startY** (number) - Optional - Y coordinate for drag start (with startX). - **endElementId** (string) - Optional - Element ID for drag end. Use *or* endX/endY. - **endX** (number) - Optional - X coordinate for drag end (with endY). - **endY** (number) - Optional - Y coordinate for drag end (with endX). - **modifierKeys** (string or string[]) - Optional - Keys to hold during drag: `shift`, `ctrl`, `alt`, `win`. - **durationMs** (number) - Optional - Duration of the move from start to end (default: 500). - **button** (string) - Optional - Mouse button: `left` (default), `middle`, `right`, `back`, `forward`. * Provide either startElementId or both startX and startY; and either endElementId or both endX and endY. ### Request Example ```json { "startX": 100, "startY": 200, "endX": 300, "endY": 400, "durationMs": 300, "modifierKeys": ["ctrl"] } ``` ### Response #### Success Response (200) This command does not return a specific value upon success. #### Response Example ```json null ``` ``` -------------------------------- ### Window Management Methods Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/GENERATION_SUMMARY.txt Methods for managing the application window and capturing screenshots. ```APIDOC ## getPageSource ### Description Gets the entire page source of the current window. ### Method GET ### Endpoint /session/{sessionId}/source ### Response #### Success Response (200) - **sessionId** (string) - The session ID. - **status** (number) - The status code (0 for success). - **value** (string) - The page source in XML format. ``` ```APIDOC ## getScreenshot ### Description Takes a screenshot of the current window. ### Method GET ### Endpoint /session/{sessionId}/screenshot ### Response #### Success Response (200) - **sessionId** (string) - The session ID. - **status** (number) - The status code (0 for success). - **value** (string) - The screenshot as a Base64 encoded string. ``` ```APIDOC ## getWindowRect ### Description Gets the dimensions and position of the current window. ### Method GET ### Endpoint /session/{sessionId}/window/rect ### Response #### Success Response (200) - **sessionId** (string) - The session ID. - **status** (number) - The status code (0 for success). - **value** (object) - An object containing 'width', 'height', 'x', and 'y' properties. ``` ```APIDOC ## setWindow ### Description Sets the position and dimensions of the current window. ### Method POST ### Endpoint /session/{sessionId}/window/rect ### Parameters #### Request Body - **width** (number) - Optional - The new width of the window. - **height** (number) - Optional - The new height of the window. - **x** (number) - Optional - The new x-coordinate of the window's top-left corner. - **y** (number) - Optional - The new y-coordinate of the window's top-left corner. ### Response #### Success Response (200) - **sessionId** (string) - The session ID. - **status** (number) - The status code (0 for success). - **value** (null) - Indicates success. ``` -------------------------------- ### Getting Element Information Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/INDEX.md Methods for retrieving information about an element. ```APIDOC ## getProperty() ### Description Gets a specific property of an element. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string** (string) - The value of the property. ### Response Example Not applicable ``` ```APIDOC ## getText() ### Description Gets the text content of an element. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string** (string) - The text content of the element. ### Response Example Not applicable ``` ```APIDOC ## getName() ### Description Gets the name of an element. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string** (string) - The name of the element. ### Response Example Not applicable ``` ```APIDOC ## getElementRect() ### Description Gets the rectangular bounding box of an element. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **Rect** (object) - The rectangular dimensions of the element. ### Response Example Not applicable ``` -------------------------------- ### active(): Promise Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/element-commands.md Gets the currently focused element. ```APIDOC ## active ### Description Gets the currently focused element. ### Method `active(): Promise` ### Returns - **Element** - The focused element ### Request Example ```typescript const focusedElement = await driver.active(); ``` ``` -------------------------------- ### App and Window Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/GENERATION_SUMMARY.txt Manages application lifecycle, window states, and captures page source and screenshots. ```APIDOC ## App and Window Commands ### Description APIs for controlling applications and managing windows. ### Window Management - **maximizeWindow()**: Maximizes the current window. - **minimizeWindow()**: Minimizes the current window. - **getRect()**: Gets the rectangle of the current window. - **getHandle()**: Gets the handle of the current window. ### App Lifecycle - **changeRootElement(elementId)**: Changes the root element for subsequent operations. - **focusElement(elementId)**: Sets focus to a specific element, potentially bringing its application to the foreground. ### Capture - **getPageSource()**: Captures the current page source. - **getScreenshot()**: Captures a screenshot of the current view. ### Window Enumeration - **getWindowHandles()**: Retrieves a list of all available window handles. - **switchToWindow(handle)**: Switches to a different window using its handle. ``` -------------------------------- ### Context Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/GENERATION_SUMMARY.txt Manages context switching between native applications and WebViews, including integration with browser drivers. ```APIDOC ## Context Commands ### Description Handles switching between different execution contexts, primarily NATIVE_APP and WEBVIEW_* ### Context Switching - **getContextHandles()**: Retrieves a list of available contexts. - **switchContext(contextName)**: Switches to the specified context. ### WebView Support - **enableWebView(options)**: Enables WebView support and configures necessary drivers. ### Browser Driver Integration - **setChromedriverPath(path)**: Sets the path to the ChromeDriver executable. - **setEdgeDriverPath(path)**: Sets the path to the EdgeDriver executable. ### WebView Type Detection - **detectWebViewType()**: Detects the type of WebView (e.g., Chrome, Edge). ### Request Routing - **routeRequests(enable)**: Configures request routing for WebViews. ``` -------------------------------- ### getOrientation Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/system-and-device-commands.md Gets the display orientation of the screen. This is a synchronous method. ```APIDOC ## getOrientation ### Description Gets the display orientation of the screen. ### Method `getOrientation(): Orientation` ### Parameters None ### Returns `'PORTRAIT' | 'LANDSCAPE'` - Current screen orientation. ### Example ```typescript const orientation = driver.getOrientation(); if (orientation === 'LANDSCAPE') { console.log('Screen is in landscape mode'); } ``` ``` -------------------------------- ### Get Focused Element Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/element-commands.md Retrieves the currently focused element on the page. ```typescript const focusedElement = await driver.active(); ``` -------------------------------- ### Action Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/GENERATION_SUMMARY.txt Implements the W3C Actions API for complex input sequences including keyboard, pointer, and wheel actions. ```APIDOC ## Action Commands ### Description Provides support for the W3C Actions API to simulate complex user interactions. ### Keyboard Actions - **handleKeyActionSequence(actions)**: Executes a sequence of keyboard actions. ### Pointer/Mouse Actions - **pointerMove(actions)**: Moves the pointer (mouse cursor). - **pointerDown(actions)**: Simulates a pointer button press. - **pointerUp(actions)**: Simulates a pointer button release. ### Wheel/Scroll Actions - **handleWheelActionSequence(actions)**: Executes a sequence of wheel (scroll) actions. ### Origin References - **viewport**: Refers to the viewport as the origin for actions. - **pointer**: Refers to the current pointer position as the origin. - **element**: Refers to a specific element as the origin. ### Timing and Easing - **easingFunctions**: Specifies easing functions for action timing. - **duration**: Defines the duration of an action sequence. ``` -------------------------------- ### System and Device Commands Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/GENERATION_SUMMARY.txt Provides access to system information, device time, and screen orientation. ```APIDOC ## System and Device Commands ### Description Retrieves system-level information and device properties. ### System Time - **getDeviceTime()**: Retrieves the current device time. ### Screen Orientation - **getOrientation()**: Gets the current screen orientation. - **setOrientation(orientation)**: Sets the screen orientation. ### Timezone Handling - **getTimezone()**: Retrieves the device's timezone. ### PowerShell Access - **getSystemInfo()**: Retrieves system information via PowerShell. ``` -------------------------------- ### Configure Application Launch Wait Time Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/configuration.md Set `ms_wait_for_app_launch` to specify the maximum time in milliseconds to wait for an application to launch and become ready. A timeout error is thrown if the application does not become ready within this period. ```python options.ms_wait_for_app_launch = 5000 # Wait up to 5 seconds ``` -------------------------------- ### windows: select Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Selects a UI element using the SelectionPattern. ```APIDOC ## windows: select ### Description Selects a UI element using the `SelectionPattern`, simulating the action of choosing the element in a selection context. ### Arguments - **element** (Element) - The UI element to select. ``` -------------------------------- ### Value Operations Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md Commands for setting and getting the value of elements that support the ValuePattern. ```APIDOC ## windows: setValue ### Description Sets the value of an element using ValuePattern. ### Method `executeScript` ### Parameters #### Path Parameters - **command** (string) - Required - The command to execute, 'windows: setValue'. - **args** (Array) - Required - An array containing the element and the value to set. - **arg1** (`Element`) - The element whose value will be set. - **arg2** (`string`) - The value to set. ### Request Example ```typescript await driver.executeScript('windows: setValue', [textBox, 'New Value']); ``` ``` ```APIDOC ## windows: getValue ### Description Gets the current value of an element supporting ValuePattern. ### Method `executeScript` ### Parameters #### Path Parameters - **command** (string) - Required - The command to execute, 'windows: getValue'. - **args** (Array) - Required - An array containing the element to read. - **arg1** (`Element`) - The element to read. ### Returns - **string** - The element's current value ### Request Example ```typescript const value = await driver.executeScript('windows: getValue', [slider]); ``` ``` -------------------------------- ### getWindowRect Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/app-and-window-commands.md Gets the bounding rectangle of the current window, including its position and dimensions. ```APIDOC ## getWindowRect ### Description Gets the bounding rectangle of the current window. ### Method `getWindowRect(): Promise` ### Returns `Promise` - Object with `x`, `y`, `width`, `height` properties ### Example ```typescript const rect = await driver.getWindowRect(); console.log(`Window: x=${rect.x}, y=${rect.y}, width=${rect.width}, height=${rect.height}`); ``` ``` -------------------------------- ### Window & App Management Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/INDEX.md Methods for managing windows and applications. ```APIDOC ## getPageSource() ### Description Gets the page source of the current window in XML format. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string** (string) - The page source in XML format. ### Response Example Not applicable ``` ```APIDOC ## getScreenshot() ### Description Gets a screenshot of the current window in base64 format. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string** (string) - The screenshot as a base64 encoded string. ### Response Example Not applicable ``` ```APIDOC ## getWindowRect() ### Description Gets the rectangular dimensions of the current window. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **Rect** (object) - The rectangular dimensions of the window. ### Response Example Not applicable ``` ```APIDOC ## getWindowHandle() ### Description Gets the handle of the current window. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string** (string) - The handle of the current window. ### Response Example Not applicable ``` ```APIDOC ## getWindowHandles() ### Description Gets the handles of all available windows. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **string[]** (array) - An array of window handles. ### Response Example Not applicable ``` ```APIDOC ## setWindow() ### Description Sets the current window. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **void** (void) - No return value. ### Response Example Not applicable ``` ```APIDOC ## maximizeWindow() ### Description Maximizes the current window. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **void** (void) - No return value. ### Response Example Not applicable ``` ```APIDOC ## minimizeWindow() ### Description Minimizes the current window. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **void** (void) - No return value. ### Response Example Not applicable ``` ```APIDOC ## changeRootElement() ### Description Changes the root element for subsequent operations. ### Method Not specified (likely part of an SDK or driver interface) ### Endpoint Not applicable ### Parameters Not specified ### Request Example Not applicable ### Response #### Success Response - **void** (void) - No return value. ### Response Example Not applicable ``` -------------------------------- ### windows: getValue Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Gets the current value of a UI element that supports the ValuePattern. ```APIDOC ## windows: getValue ### Description Gets the current value of a UI element that supports the `ValuePattern` (e.g., a text box). ### Arguments - **element** (Element) - The UI element from which to retrieve the value. ``` -------------------------------- ### Execute Custom Windows Commands (Ruby) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Use this snippet to execute custom Windows commands with arguments in Ruby. The command name and arguments are passed as strings. Arguments can be provided as a hash. ```ruby result = @driver.execute_script 'windows: ', { arg1: 'value1', arg2: 'value2', } ``` -------------------------------- ### windows: allSelectedItems Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Gets all selected items from a UI element that supports the SelectionPattern. ```APIDOC ## windows: allSelectedItems ### Description Gets all selected items from a UI element that supports the `SelectionPattern`, useful for lists or combo boxes. ### Arguments - **element** (Element) - The UI element from which to retrieve all selected items. ### Returns - **Element[]**: An array of selected items as Appium elements. ``` -------------------------------- ### windows: selectedItem Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Gets the selected item from a UI element that supports the SelectionPattern. ```APIDOC ## windows: selectedItem ### Description Gets the selected item from a UI element that supports the `SelectionPattern`. ### Arguments - **element** (Element) - The UI element from which to retrieve the selected item. ### Returns - **Element**: The selected item of the element as an Appium element. ``` -------------------------------- ### Execute Custom Windows Commands (Java) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Use this snippet to execute custom Windows commands with arguments. The command name and arguments are passed as strings. Arguments can be provided as a map. ```java var result = driver.executeScript("windows: ", Map.of( "arg1", "value1", "arg2", "value2" // you may add more pairs if needed or skip providing the map completely // if all arguments are defined as optional )); ``` -------------------------------- ### getCurrentContext Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/context-commands.md Gets the currently active automation context. Returns the context ID, which can be 'NATIVE_APP' or 'WEBVIEW_'. ```APIDOC ## getCurrentContext(): Promise ### Description Gets the currently active automation context. ### Returns - `Promise` - Context ID: `'NATIVE_APP'` or `'WEBVIEW_'` ### Example ```typescript const context = await driver.getCurrentContext(); if (context === 'NATIVE_APP') { console.log('In native Windows UI context'); } ``` ``` -------------------------------- ### Execute PowerShell Commands to Control Notepad Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Demonstrates executing a PowerShell script to control the Notepad application, including showing and hiding its window. This requires the 'powerShell' capability to be enabled on the Appium server. ```java // java String psScript = "$sig = '[DllImport(\"user32.dll\")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'\n" + "Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32\n" + "Start-Process Notepad\n" + "$hwnd = @(Get-Process Notepad)[0].MainWindowHandle\n" + "[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)\n" + "[Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)\n" + "Stop-Process -Name Notepad"; driver.executeScript("powerShell", psScript); ``` -------------------------------- ### Execute Custom Windows Commands (Dotnet) Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/README.md Use this snippet to execute custom Windows commands with arguments in Dotnet. The command name and arguments are passed as strings. Arguments can be provided as a dictionary. ```csharp object result = driver.ExecuteScript("windows: ", new Dictionary() { {"arg1", "value1"}, {"arg2", "value2"} }); ``` -------------------------------- ### Get Page Source XML Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/powershell-commands.md Generates an XML representation of the automation tree for the current root element. ```powershell Get-PageSource $rootElement | ForEach-Object { $_.OuterXml } ``` -------------------------------- ### Get Element Value with ValuePattern Source: https://github.com/automatetheplanet/appium-novawindows-driver/blob/main/_autodocs/api-reference/extension-commands.md Retrieves the current value of an element that supports the ValuePattern. Pass the element as an argument. ```typescript const value = await driver.executeScript('windows: getValue', [slider]); ```