### Initializing Page Theme and Display - JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This JavaScript snippet initializes the page theme based on local storage or OS preference and manages the initial display of the body element, showing it after a short delay or via an app.showPage() call. It's typically used for initial UI setup. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Configuring Environment Variables for Tauri E2E - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This section configures environment variables crucial for @tauri-e2e/selenium. It sets the path to the Tauri app binary, dynamically installs the WebDriver binary, defines the Selenium remote server URL, and specifies the WebDriver logging level. These variables streamline WebDriver and Tauri app integration. ```TypeScript // This setup simplifies managing `WebDriver` binary locations and platform-specific details. // The following `optional` environment variables can be set to quickly get started. // Under the hood all modules recognize them and adjust their behavior accordingly. // Note!: This is optional and opinionated, you can manage the WebDriver process yourself. // Path to the Tauri app binary. // (if .exe is detected it will be stripped on non-Windows platforms) process.env.TAURI_SELENIUM_BINARY = '../../../target/release/tauri-app.exe'; // Path to the WebDriver binary (optional as it will be looked up in the system's PATH). // In this example we use `install` module to install the WebDriver binary based on the platform. // On `Windows` we will automatically download the WebDriver binary while utilizing cache. // On `Linux` if the WebDriver binary is not found in the PATH, we will throw an error as // WebDriver has to be installed using native package manager like `apt-get` or `yum`. // Note: For running Windows tests inside GitHub Actions see: // https://github.com/actions/runner-images/issues/9538 process.env.TAURI_WEBDRIVER_BINARY = await e2e.install.PlatformDriver(); // Define URL of the remote Selenium server. // That's how we connect these two modules together: // - If spawning WebDriver using `launch.SpawnWebDriver` module - host and port // arguments passed to the WebDriver binary will be extracted from this URL. // - If using `Builder` then host and port will be passed // to `usingServer` method of `selenium-webdriver`. This aligns with the // `selenium-webdriver` API and allows to use custom remote servers. process.env.SELENIUM_REMOTE_URL = 'http://127.0.0.1:4674'; // Loge level for WebDriver process. process.env.TAURI_WEBDRIVER_LOGLEVEL = 'debug'; ``` -------------------------------- ### Launching WebDriver Process for Tauri E2E - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This snippet launches the WebDriver process using `e2e.launch.spawnWebDriver`. The `setupExitHandlers: true` option ensures proper cleanup of the WebDriver process upon script exit, abstracting away complexities of managing different WebDriver binaries. ```TypeScript // Launch WebDriver process. // Handles cleanup on process exit under the hood (SIGINT, SIGTERM, etc). // Because each WebDriver has its own way of spawning and managing the process, // we abstract this complexity into a single module while trying to keep the API simple. let webdriver = await e2e.launch.spawnWebDriver({setupExitHandlers: true}) ``` -------------------------------- ### Initializing and Running Tauri E2E Tests with Selenium in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/examples/quick-start.md This snippet demonstrates a complete workflow for setting up, launching, and tearing down an end-to-end test environment for a Tauri application using `@tauri-e2e/selenium` and `selenium-webdriver`. It covers configuring environment variables for the Tauri binary, WebDriver binary, and Selenium remote URL, as well as managing the WebDriver process and session. It also shows how to perform a basic assertion on the application's title. ```javascript import {launch} from "@tauri-e2e/selenium"; import assert from "node:assert"; import {until} from "selenium-webdriver"; import * as e2e from "@tauri-e2e/selenium" // This setup simplifies managing `WebDriver` binary locations and platform-specific details. // The following `optional` environment variables can be set to quickly get started. // Under the hood all modules recognize them and adjust their behavior accordingly. // Note!: This is optional and opinionated, you can manage the WebDriver process yourself. // Path to the Tauri app binary. // (if .exe is detected it will be stripped on non-Windows platforms) process.env.TAURI_SELENIUM_BINARY = '../../../target/release/tauri-app.exe'; // Path to the WebDriver binary (optional as it will be looked up in the system's PATH). // In this example we use `install` module to install the WebDriver binary based on the platform. // On `Windows` we will automatically download the WebDriver binary while utilizing cache. // On `Linux` if the WebDriver binary is not found in the PATH, we will throw an error as // WebDriver has to be installed using native package manager like `apt-get` or `yum`. // Note: For running Windows tests inside GitHub Actions see: // https://github.com/actions/runner-images/issues/9538 process.env.TAURI_WEBDRIVER_BINARY = await e2e.install.PlatformDriver(); // Define URL of the remote Selenium server. // That's how we connect these two modules together: // - If spawning WebDriver using `launch.SpawnWebDriver` module - host and port // arguments passed to the WebDriver binary will be extracted from this URL. // - If using `Builder` then host and port will be passed // to `usingServer` method of `selenium-webdriver`. This aligns with the // `selenium-webdriver` API and allows to use custom remote servers. process.env.SELENIUM_REMOTE_URL = 'http://127.0.0.1:4674'; // Loge level for WebDriver process. process.env.TAURI_WEBDRIVER_LOGLEVEL = 'debug'; // Setup optional logging in case of failures. e2e.setLogger(console); // Launch WebDriver process. // Handles cleanup on process exit under the hood (SIGINT, SIGTERM, etc). // Because each WebDriver has its own way of spawning and managing the process, // we abstract this complexity into a single module while trying to keep the API simple. let webdriver = await e2e.launch.spawnWebDriver({setupExitHandlers: true}) // Create a new WebDriver session. let driver = new e2e.selenium.Builder().build(); // Wait until the body is loaded. await driver.wait(until.elementLocated({css: 'body'})); // Get the title. let title = await driver.getTitle(); assert.equal(title, 'Tauri App', await driver.getPageSource()); // Properly cleanup WebDriver session. // This will close the Tauri window and the WebDriver session. // Note: on Linux need this PR to be merged: // - https://github.com/tauri-apps/wry/pull/1311/files await e2e.selenium.cleanupSession(driver); // Close underlying WebDriver process. // Otherwise, we will hang indefinitely. // Note: When using node runner you can pass `--test-force-exit` flag. e2e.launch.killWebDriver(webdriver) ``` -------------------------------- ### Importing Core Modules for Tauri E2E Testing - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This snippet imports necessary modules for end-to-end testing with Tauri applications. It includes 'launch' for WebDriver management, 'assert' for assertions, 'until' for Selenium wait conditions, and 'e2e' as a namespace for @tauri-e2e/selenium utilities. ```TypeScript import {launch} from "@tauri-e2e/selenium"; import assert from "node:assert"; import {until} from "selenium-webdriver"; import * as e2e from "@tauri-e2e/selenium" ``` -------------------------------- ### Initializing Webview2 Theme and Display - JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.selenium.webview2.html This JavaScript snippet handles the initial setup of the application's theme, retrieving it from local storage or defaulting to the 'os' theme. It also manages the initial display of the body, hiding it temporarily and then revealing it after a 500ms delay, or when an 'app' object signals readiness, to prevent a flash of unstyled content or ensure proper rendering. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Setting Up Optional Logger for Tauri E2E - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This line sets up an optional logger for @tauri-e2e/selenium to `console`. This allows for logging messages, especially useful for debugging failures during test execution. ```TypeScript // Setup optional logging in case of failures. e2e.setLogger(console); ``` -------------------------------- ### Initializing Page Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.logger.setLogger.html This JavaScript snippet handles the initial setup of the page's theme by retrieving it from local storage or defaulting to 'os'. It then hides the body to prevent a flash of unstyled content and, after a brief delay, either shows the application page or removes the display property from the body. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Installing Tauri E2E Selenium Package (Shell) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/examples/installation.md This command installs the `@tauri-e2e/selenium` package as a development dependency using npm. It should be run in the project's root directory. ```shell npm install @tauri-e2e/selenium --save-dev ``` -------------------------------- ### Initializing Page Theme and Display (JavaScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.install.html This JavaScript snippet initializes the page's theme from local storage, defaulting to 'os' if not found. It then hides the document body to prevent a flash of unstyled content and, after a 500ms delay, either shows a specific application page (if 'app' is defined) or makes the body visible again. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Installing Tauri E2E Selenium Package with npm Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/1__Installation.html This shell command uses `npm` to install the `@tauri-e2e/selenium` package. The `--save-dev` flag ensures it is added as a development dependency, suitable for end-to-end testing setups within a project. ```Shell npm install @tauri-e2e/selenium --save-dev ``` -------------------------------- ### Getting Selenium Capabilities with optionsForPlatform (JavaScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.selenium.optionsForPlatform.html This JavaScript example demonstrates various ways to use the `optionsForPlatform` function to retrieve Selenium capabilities. It shows how to get capabilities for the current platform, for specific platforms like 'Linux' or 'Windows', and for specific platform-webview combinations such as 'Linux' with 'webkitgtk2' or 'Windows' with 'webview2'. ```JavaScript // Get capabilities for the current platformlet capabilities = capabilitiesForPlatform(); // Get capabilities for specific platformlet capabilities = capabilitiesForPlatform("Linux"); let capabilities = capabilitiesForPlatform("Windows"); // Get capabilities for specific platform and webviewlet capabilities = capabilitiesForPlatform("Linux", "webkitgtk2"); let capabilities = capabilitiesForPlatform("Windows", "webview2"); ``` -------------------------------- ### Creating New Selenium WebDriver Session - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This code creates a new Selenium WebDriver session. It uses `e2e.selenium.Builder().build()` to instantiate a WebDriver instance, which will then be used to interact with the Tauri application. ```TypeScript // Create a new WebDriver session. let driver = new e2e.selenium.Builder().build(); ``` -------------------------------- ### Interacting with Tauri App and Asserting Title - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This snippet demonstrates basic interaction with the Tauri application. It waits until the `body` element is located, retrieves the application's title, and then asserts that the title matches 'Tauri App', verifying the application's state. ```TypeScript // Wait until the body is loaded. await driver.wait(until.elementLocated({css: 'body'})); // Get the title. let title = await driver.getTitle(); assert.equal(title, 'Tauri App'); ``` -------------------------------- ### Cleaning Up WebDriver Session and Process - TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/2__Quickstart_Guide.html This crucial snippet handles the cleanup of the WebDriver session and process. `e2e.selenium.cleanupSession(driver)` closes the Tauri window and the WebDriver session, while `e2e.launch.killWebDriver(webdriver)` terminates the underlying WebDriver process, preventing indefinite hangs. ```TypeScript // Properly cleanup WebDriver session. // This will close the Tauri window and the WebDriver session. // Note: on Linux need this PR to be merged: // - https://github.com/tauri-apps/wry/pull/1311/files await e2e.selenium.cleanupSession(driver); // Close underlying WebDriver process. // Otherwise, we will hang indefinitely. // Note: When using node runner you can pass `--test-force-exit` flag. e2e.launch.killWebDriver(webdriver) ``` -------------------------------- ### Initializing Selenium WebDriver for Tauri E2E in TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/3__Selenium_API.html This TypeScript example demonstrates how to set up a Selenium WebDriver instance using `@tauri-e2e/selenium`. It shows platform-specific configurations for Windows (WebView2) and Linux (WebKitGTK2), allowing the WebDriver to connect to a Tauri application by specifying its binary path. ```TypeScript import {Builder} from "selenium-webdriver"; import * as e2e from "@tauri-e2e/selenium" // Using native selenium-webdriver API: // Windows let opts = new e2e.webview2.Options() opts.setBinaryPath("/path/to/tauri-app.exe") let driver = new Builder() .withCapabilities(opts) // Linux let opts = new e2e.webkitgtk2.Options() opts.setBinaryPath("/path/to/tauri-app") let driver = new Builder() .withCapabilities(opts) ``` -------------------------------- ### Getting Basic Firefox Capabilities (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves a basic set of capabilities for the Firefox browser. This method is inherited from `edge.Options.firefox` and is defined in the `selenium-webdriver` type definitions. ```TypeScript firefox(): Capabilities ``` -------------------------------- ### Getting Basic Chrome Capabilities (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves a basic set of capabilities for the Chrome browser. This method is inherited from `edge.Options.chrome` and is defined in the `selenium-webdriver` type definitions. ```TypeScript chrome(): Capabilities ``` -------------------------------- ### Getting Basic Internet Explorer Capabilities (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves a basic set of capabilities for the Internet Explorer browser. This method is inherited from `edge.Options.ie` and is defined in the `selenium-webdriver` type definitions. ```TypeScript ie(): Capabilities ``` -------------------------------- ### Getting Basic Edge Capabilities (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves a basic set of capabilities for the Microsoft Edge browser. This method is inherited from `edge.Options.edge` and is defined in the `selenium-webdriver` type definitions. ```TypeScript edge(): Capabilities ``` -------------------------------- ### Getting Basic Safari Capabilities (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves a basic set of capabilities for the Safari browser. This method is inherited from `edge.Options.safari` and is defined in the `selenium-webdriver` type definitions. ```TypeScript safari(): Capabilities ``` -------------------------------- ### Configuring Mobile Emulation with Custom Screen Metrics in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html This example illustrates how to set up mobile emulation using custom screen dimensions and pixel ratio. It configures `chrome.Options` with specific `width`, `height`, and `pixelRatio` values for the emulated device, then uses these options to create a new WebDriver session. ```JavaScript let options = new chrome.Options().setMobileEmulation({deviceMetrics: { width: 360, height: 640, pixelRatio: 3.0 }}); let driver = chrome.Driver.createSession(options); ``` -------------------------------- ### Configuring and Building Selenium WebDriver with Tauri in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.Builder.html This example demonstrates how to configure the `Builder` class by setting environment variables for the Tauri application binary path (`TAURI_SELENIUM_BINARY`) and the Selenium remote server URL (`SELENIUM_REMOTE_URL`). It then instantiates a new `Builder` and calls its `build()` method to create a `WebDriver` instance, which is used for browser automation. ```JavaScript process.env.TAURI_SELENIUM_BINARY = '../../../target/debug/tauri-app.exe'; process.env.SELENIUM_REMOTE_URL = 'http://127.0.0.1:4674'; let builder = new Builder().build(); ``` -------------------------------- ### Adding Browser Extensions - Chromium Options (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Adds one or more extensions to be installed when the browser is launched. Extensions can be specified as paths to packed CRX files or as Buffer objects. This is useful for testing applications that rely on specific browser extensions. ```TypeScript addExtensions(...args: (string | Buffer)[]): Options ``` -------------------------------- ### Initializing Theme and Display in Tauri E2E Selenium Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.launch.html This JavaScript snippet serves as an entry point for the `launch` module, setting the document's theme based on local storage or OS preference. It initially hides the body and then shows the page after a delay, or removes the display property if `app` is not defined, ensuring a smooth loading experience. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Page Display - JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.install.PlatformDriver.html This snippet initializes the application's theme based on `localStorage` or defaults to 'os', hides the body initially, and then shows the page after a 500ms delay. This is likely to prevent a flash of unstyled content or wait for the application to be ready. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Display in WebKitGtk2Driver JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.install.WebKitGtk2Driver.html This JavaScript snippet is executed on page load to initialize the theme based on `localStorage` or default to 'os'. It initially hides the document body to prevent FOUC (Flash of Unstyled Content) and then reveals it after a 500ms delay, potentially showing a splash screen or ensuring `app.showPage()` is called if `app` is defined. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Page Theme and Display (JavaScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.selenium.optionsForPlatform.html This JavaScript snippet initializes the page's theme based on `localStorage` or defaults to 'os'. It then hides the body to prevent a flash of unstyled content and uses a `setTimeout` to show the page after 500ms, either by calling `app.showPage()` if `app` exists, or by removing the `display: none` style from the body. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Page Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/interfaces/_tauri_e2e_selenium.logger.Logger.html This JavaScript snippet initializes the document's theme based on local storage or defaults to 'os'. It then hides the body, and after a 500ms delay, either shows the application page (`app.showPage()`) or removes the `display: none` style from the body, ensuring a smooth page load or theme application. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Theme and Manage Body Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webkitgtk2.Options.html This JavaScript snippet initializes the document's theme based on local storage or OS preference, hides the body, and then shows it after a delay, potentially via an `app.showPage()` call if `app` is defined. It ensures a smooth initial page load experience by preventing a flash of unstyled content. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Display for WebkitGTK2 (JavaScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.selenium.webkitgtk2.html This JavaScript snippet initializes the application's theme based on a value stored in local storage ('tsd-theme') or defaults to 'os' if not found. It then hides the document body to prevent a flash of unstyled content and, after a 500ms delay, either shows the application page (if 'app' object exists) or removes the display property from the body, ensuring a smooth initial load experience. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Page Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.html This JavaScript snippet initializes the page's theme based on local storage or defaults to 'os'. It initially hides the body to prevent a flash of unstyled content, then reveals it after a 500ms delay, potentially showing an app page if available. This ensures a smoother user experience during page load. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing UI Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.Builder.html This JavaScript snippet initializes the UI theme based on `localStorage` or defaults to 'os'. It initially hides the body to prevent a flash of unstyled content, then after a 500ms delay, it either shows a specific application page (`app.showPage()`) or removes the `display: none` style from the body, making the content visible. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initialize Page Theme and Display - JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.launch.spawnWebDriver.html This JavaScript code snippet manages the page's visual theme by retrieving it from local storage or defaulting to 'os'. It initially hides the document body to prevent FOUC (Flash of Unstyled Content) and then makes it visible after a short delay, potentially showing an application page if available. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Document Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/1__Installation.html This JavaScript code snippet sets the document's theme from `localStorage` or defaults to the 'os' theme. It initially hides the document body to prevent a flash of unstyled content and then reveals it after a 500ms delay, potentially waiting for application rendering or initialization. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Page Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/documents/3__Selenium_API.html This JavaScript snippet initializes the page's theme based on local storage or defaults to 'os'. It also hides the body initially and then shows it after a delay, potentially waiting for an 'app' object to be ready, preventing a flash of unstyled content. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Page Display with JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/index.html This JavaScript snippet initializes the document's theme based on a value retrieved from local storage (key 'tsd-theme') or defaults to 'os' if not found. It then immediately hides the document body to prevent a flash of unstyled content (FOUC). After a 500ms delay, it attempts to show a page using an 'app' object (if it exists and has a 'showPage' method) or, as a fallback, removes the 'display' style from the body to make it visible. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing UI Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.selenium.cleanupSession.html This JavaScript snippet initializes the UI theme based on local storage or defaults to 'os' (operating system theme). It also initially hides the body and then shows the application page or removes the display property after a 500ms delay, likely to prevent a flash of unstyled content (FOUC). ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing UI Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html This snippet initializes the document's theme from local storage or defaults to 'os', hides the body, and then shows the page after a delay, removing the display property. It's typically used for preventing a flash of unstyled content (FOUC) during page load. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Hiding Body in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.install.EdgeDriver.html This JavaScript snippet manages the initial display of the application body and applies a theme. It retrieves the theme from `localStorage` or defaults to 'os', hides the body, and then, after a delay, either shows a specific page or makes the body visible. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing UI Theme and Display State in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.logger.html This JavaScript snippet executes on page load to configure the UI theme and manage the initial display of the document body. It retrieves the theme preference from local storage, defaulting to 'os' if not found, and applies it. The body is initially hidden to prevent a flash of unstyled content, then revealed after a short delay or immediately if an 'app' object is available, ensuring a smoother user experience. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Theme and Display in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/functions/_tauri_e2e_selenium.launch.killWebDriver.html This snippet initializes the document's theme based on local storage or OS preference. It then temporarily hides the body to prevent Flash of Unstyled Content (FOUC) and removes the display property after a 500ms delay, optionally showing an 'app' page if available. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Selenium WebDriver for Tauri E2E (Linux) - JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/examples/selenium-api.md This snippet illustrates how to initialize a Selenium WebDriver for a Tauri application on Linux. It utilizes `webkitgtk2.Options` from `@tauri-e2e/selenium` to set the binary path of the Tauri executable, allowing WebDriver to interact with the application's WebKitGTK2 instance. The `Builder` from `selenium-webdriver` then constructs the driver with the specified capabilities. ```javascript import {Builder} from "selenium-webdriver"; import * as e2e from "@tauri-e2e/selenium" // Using native selenium-webdriver API: // Linux let opts = new e2e.webkitgtk2.Options() opts.setBinaryPath("/path/to/tauri-app") let driver = new Builder() .withCapabilities(opts) ``` -------------------------------- ### Initializing Page Theme and Display (JavaScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/modules/_tauri_e2e_selenium.selenium.html This JavaScript snippet initializes the page's theme based on a value stored in local storage ('tsd-theme') or defaults to 'os' (operating system preference) if not found. It initially hides the document body to prevent a flash of unstyled content (FOUC). After a 500ms delay, it checks if an 'app' object exists; if so, it calls 'app.showPage()', otherwise it removes the 'display' style property from the body, making it visible. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Initializing Selenium WebDriver for Tauri E2E (Windows) - JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/examples/selenium-api.md This snippet demonstrates how to initialize a Selenium WebDriver for a Tauri application on Windows. It uses `webview2.Options` from `@tauri-e2e/selenium` to specify the path to the Tauri executable, enabling WebDriver to control the application's WebView2 instance. The `Builder` from `selenium-webdriver` then creates the driver instance with these capabilities. ```javascript import {Builder} from "selenium-webdriver"; import * as e2e from "@tauri-e2e/selenium" // Using native selenium-webdriver API: // Windows let opts = new e2e.webview2.Options() opts.setBinaryPath("/path/to/tauri-app.exe") let driver = new Builder() .withCapabilities(opts) ``` -------------------------------- ### Adding Command Line Arguments to Browser (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Appends additional command-line arguments for launching the browser. Arguments can be specified with or without the "--" prefix, and values should be delimited by "=". It accepts a rest parameter `...args` of type `string[]` and returns a self-reference to the `Options` object. ```TypeScript addArguments(...args: string[]): Options ``` -------------------------------- ### Setting Initial Window Size (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets the initial dimensions for the browser window. The `size` parameter is an object containing `width` and `height` properties, both of type `number`. This method returns a self-reference to the `Options` object and throws an error if width or height are invalid. ```TypeScript windowSize(size: { width: number; height: number; }): Options ``` -------------------------------- ### Configuring Mobile Emulation with Pre-configured Device in JavaScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html This snippet demonstrates how to configure mobile emulation for a Chrome browser using a pre-configured device name, 'Google Nexus 5'. It initializes `chrome.Options` and applies the mobile emulation setting before creating a new WebDriver session. ```JavaScript let options = new chrome.Options().setMobileEmulation( {deviceName: 'Google Nexus 5'}); let driver = chrome.Driver.createSession(options); ``` -------------------------------- ### Setting Edge Chromium Binary Path (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets the absolute or relative path to the Microsoft Edge Chromium binary to be used by `msedgedriver`. The specified path must exist on the machine launching the browser. It takes a `path` string and returns a self-reference to the `Options` object. ```TypeScript setEdgeChromiumBinaryPath(path: string): Options ``` -------------------------------- ### Connecting to Chromium Remote Debugging Server (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Configures the address of a Chromium remote debugging server for connection. The address should be in the format "{hostname|IP address}:port", such as "localhost:9222". It takes an `address` string and returns a self-reference to the `Options` object. ```TypeScript debuggerAddress(address: string): Options ``` -------------------------------- ### Setting Target Platform in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets the target platform for the WebDriver session. This method takes a string `platform` and returns a self-reference to the `Capabilities` object for chaining. It is inherited from `edge.Options`. ```TypeScript setPlatform(platform: string): Capabilities ``` -------------------------------- ### Setting Browser Binary Path - Chromium Options (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Specifies the absolute or relative path to the browser executable to be used by ChromeDriver. This is crucial when the browser binary is not in a standard location or when testing a specific browser build. On macOS, ensure the path points to the actual executable inside the application bundle. ```TypeScript setBinaryPath(path: string): Options ``` -------------------------------- ### Retrieving Target Platform in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves the configured target platform for the WebDriver session. This method returns a string if the platform is set, otherwise `undefined`. It is inherited from `edge.Options`. ```TypeScript getPlatform(): undefined | string ``` -------------------------------- ### Setting Page Load Strategy in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets the desired page loading strategy for a new WebDriver session. This method accepts a string `strategy` and returns a self-reference to the `Capabilities` object for chaining. It is inherited from `edge.Options`. ```TypeScript setPageLoadStrategy(strategy: string): Capabilities ``` -------------------------------- ### Configuring Performance Logging Preferences - Chromium Options (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets preferences for collecting performance logs from the browser's DevTools. This includes options to enable network, page, and timeline event collection, specify tracing categories, and define the interval for buffer usage reporting, aiding in performance analysis and debugging. ```TypeScript setPerfLoggingPrefs(prefs: { enableNetwork: boolean; enablePage: boolean; enableTimeline: boolean; traceCategories: string; bufferUsageReportingInterval: number; }): Options ``` -------------------------------- ### Excluding Chrome Command Line Switches - Chromium Options (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Configures the ChromeDriver to exclude specific command-line switches that it would normally pass when launching Chrome. This allows fine-grained control over the browser's startup behavior. Parameters are variadic strings representing the switches to exclude, without the '--' prefix. ```TypeScript excludeSwitches(...args: string[]): Options ``` -------------------------------- ### Retrieving Page Load Strategy in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Returns the configured page load strategy for the WebDriver session. This method returns a string if the strategy is set, otherwise `undefined`. It is inherited from `edge.Options`. ```TypeScript getPageLoadStrategy(): undefined | string ``` -------------------------------- ### Setting User Profile Preferences - Chromium Options (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Applies custom user preferences to Chrome's profile. This allows configuring various browser settings, such as default download directories, language settings, or experimental features, by providing a dictionary of preferences. ```TypeScript setUserPreferences(prefs: object): Options ``` -------------------------------- ### Enabling WebView2 Automation (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Modifies the browser name to 'webview2' to enable test automation for WebView2 applications using Microsoft Edge WebDriver. It takes a boolean `enable` flag to activate or deactivate this feature and returns `void`. ```TypeScript useWebView(enable: boolean): void ``` -------------------------------- ### Defining Logger Interface in TypeScript Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/interfaces/_tauri_e2e_selenium.logger.Logger.html This TypeScript interface defines the `Logger` contract, specifying four methods: `info`, `warn`, `error`, and `debug`. Each method accepts a `string` `data` argument and an arbitrary number of additional arguments, returning `void`. This interface ensures consistent logging functionality across the library. ```TypeScript interface Logger { info: ((data: string, ...args: any) => void); warn: ((data: string, ...args: any) => void); error: ((data: string, ...args: any) => void); debug: ((data: string, ...args: any) => void); } ``` -------------------------------- ### Setting Browser Version in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets the desired version of the target browser for the WebDriver session. This method takes a string `version` and returns a self-reference to the `Capabilities` object for chaining. It is inherited from `edge.Options`. ```TypeScript setBrowserVersion(version: string): Capabilities ``` -------------------------------- ### Setting Insecure Certificate Acceptance in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Configures a WebDriver session to implicitly accept self-signed or untrusted TLS certificates during navigation. This method takes a boolean parameter `accept` to enable or disable this behavior and returns a self-reference to the `Capabilities` object for method chaining. It is inherited from `edge.Options`. ```TypeScript setAcceptInsecureCerts(accept: boolean): Capabilities ``` -------------------------------- ### Retrieving Browser Version in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves the configured version of the target browser for the WebDriver session. This method returns a string if the browser version is set, otherwise `undefined`. It is inherited from `edge.Options`. ```TypeScript getBrowserVersion(): undefined | string ``` -------------------------------- ### Retrieving Insecure Certificate Acceptance Setting in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves the current configuration of whether the WebDriver session is set to accept insecure TLS certificates. This method returns a boolean value indicating the setting. It is inherited from `edge.Options`. ```TypeScript getAcceptInsecureCerts(): boolean ``` -------------------------------- ### Setting Browser Name in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Sets the name of the target browser for the WebDriver session. This method accepts a string `name` representing the browser and returns a self-reference to the `Capabilities` object for chaining. It is inherited from `edge.Options`. ```TypeScript setBrowserName(name: string): Capabilities ``` -------------------------------- ### Controlling Browser Detachment - Chromium Options (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Determines whether the launched browser process should continue running if the ChromeDriver service is terminated before `webdriver.WebDriver#quit()` is explicitly called. Setting this to `true` can be useful for debugging or manual inspection after test execution. ```TypeScript detachDriver(detach: boolean): Options ``` -------------------------------- ### Retrieving Browser Name in Selenium WebDriver (TypeScript) Source: https://github.com/bukowa/tauri-e2e/blob/master/selenium/javascript/docs/classes/_tauri_e2e_selenium.selenium.webview2.Options.html Retrieves the configured name of the target browser for the WebDriver session. This method returns a string if the browser name is set, otherwise `undefined`. It is inherited from `edge.Options`. ```TypeScript getBrowserName(): undefined | string ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.