### Selenoid Manual Start Output Example Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Example console output when starting Selenoid manually, showing configuration loading and listening port. ```text 2017/11/26 21:23:43 Loading configuration files... 2017/11/26 21:23:43 Loaded configuration from [config/browsers.json] ... 2017/11/26 21:23:43 Listening on :4444 ``` -------------------------------- ### Basic Selenoid Configuration Example Source: https://github.com/aerokube/selenoid/blob/master/docs/cli-flags.adoc Demonstrates how to start Selenoid with a custom browser configuration file and a specified limit for simultaneous container runs. ```bash $ ./selenoid -conf ~/.aerokube/selenoid/browsers.json -limit 10 ``` -------------------------------- ### Start Selenoid with Configuration Manager Source: https://github.com/aerokube/selenoid/blob/master/README.md Use the Configuration Manager to start Selenoid with VNC and tmpfs enabled. This is a quick way to get Selenoid up and running. ```bash $ ./cm selenoid start --vnc --tmpfs 128 ``` -------------------------------- ### Start Selenoid Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc Run this command to start Selenoid with VNC support. Avoid using sudo. ```bash $ ./cm selenoid start --vnc ``` -------------------------------- ### Start Selenoid UI Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc Optionally, run this command to start the Selenoid UI. ```bash $ ./cm selenoid-ui start ``` -------------------------------- ### Start Selenoid Binary (Windows) Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Execute the downloaded Selenoid binary on Windows. The executable name may include '.exe'. ```bash selenoid.exe ``` -------------------------------- ### Start Selenoid Binary (*nix) Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Execute the downloaded Selenoid binary directly on Unix-like systems. Ensure the binary has execute permissions. ```bash ./selenoid ``` -------------------------------- ### Example browsers.json Configuration Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Defines browser configurations, including image, port, and path. Ensure 'path' is set correctly for different browsers. ```json { "firefox": { "default": "57.0", "versions": { "57.0": { "image": "selenoid/firefox:88.0", "port": "4444", "path": "/wd/hub" } } } } ``` -------------------------------- ### Running Selenoid with Custom Logging Configuration Source: https://github.com/aerokube/selenoid/blob/master/docs/logging-configuration-file.adoc Demonstrates how to use the -log-conf flag to specify a custom logging configuration file when starting Selenoid. ```bash $ ./selenoid -log-conf /path/to/logging.json ... ``` -------------------------------- ### Start Selenoid Docker Container (*nix) Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Run Selenoid as a Docker container on Unix-like systems. Mounts the Docker socket and configuration directory. ```bash docker run -d \ --name selenoid \ -p 4444:4444 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /your/directory/config/:/etc/selenoid/:ro \ aerokube/selenoid:latest-release ``` -------------------------------- ### Windows Docker Volume Mount Example Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Demonstrates the correct format for mounting volumes in Docker on Windows, including path conversion and the special handling for docker.sock. ```bash docker run -d --name selenoid ` -p 4444:4444 ` -v //var/run/docker.sock:/var/run/docker.sock ` -v /c/Users/admin/selenoid:/etc/selenoid:ro ` aerokube/selenoid:latest-release ``` -------------------------------- ### Start Telegraf Container Source: https://github.com/aerokube/selenoid/blob/master/docs/usage-statistics.adoc Run the Telegraf container, mounting the generated configuration file and using host networking to access Selenoid. This will start sending metrics to the configured Graphite host. ```bash # docker run --net host -d \ --name telegraf \ -v /etc/telegraf:/etc \ telegraf:alpine --config /etc/telegraf.conf ``` -------------------------------- ### Accessing Developer Tools API with Webdriver.io and Puppeteer Source: https://github.com/aerokube/selenoid/blob/master/docs/devtools.adoc This example demonstrates how to connect to the Chrome Developer Tools API using Webdriver.io to start a session and Puppeteer-core to interact with the browser. It requires a running Selenoid instance and Chrome 63+. ```javascript const { remote } = require('webdriverio'); const puppeteer = require('puppeteer-core'); const host = 'selenoid.example.com'; (async () => { const browser = await remote({ hostname: host, capabilities: { browserName: 'chrome', browserVersion: '75.0' } }); const devtools = await puppeteer.connect( { browserWSEndpoint: `ws://${host}:4444/devtools/${browser.sessionId}` } ); const page = await devtools.newPage(); await page.goto('http://aerokube.com'); await page.screenshot({path: 'screenshot.png'}); const title = await page.title(); console.log(title); await devtools.close(); await browser.deleteSession(); })().catch((e) => console.error(e)); ``` -------------------------------- ### Example Session Metadata JSON Source: https://github.com/aerokube/selenoid/blob/master/docs/metadata.adoc This is an example of the JSON file that Selenoid automatically saves when the metadata feature is enabled and the -log-output-dir flag is set. It contains session ID, capabilities, and start/finish times. ```json { "id": "62a4d82d-edf6-43d5-886f-895b77ff23b7", "capabilities": { "browserName": "chrome", "version": "70.0", "name": "MyCoolTest", "screenResolution": "1920x1080x24" }, "started": "2018-11-15T16:23:12.440916+03:00", "finished": "2018-11-15T16:23:12.480928+03:00" } ``` -------------------------------- ### Custom S3 Key Pattern Example Source: https://github.com/aerokube/selenoid/blob/master/docs/s3.adoc Use the -s3-key-pattern flag to define a custom path structure for uploaded files in S3, utilizing placeholders for session details. This example organizes files by browser name and session ID. ```bash ./selenoid -s3-key-pattern $browserName/$sessionId/log.txt ``` -------------------------------- ### Docker Command for Selenoid on Windows with Video Recording Source: https://github.com/aerokube/selenoid/blob/master/docs/video.adoc Example Docker command for running Selenoid with video recording on Windows using PowerShell. It demonstrates volume creation and setting absolute paths for video output. ```bash > docker volume create selenoid-videos > $current = $PWD -replace "\\", "/" -replace "C", "c" <1> > docker run -d ` --name selenoid ` -p 4444:4444 ` -v //var/run/docker.sock:/var/run/docker.sock ` -v ${current}/config/:/etc/selenoid/:ro ` -v /c/selenoid/video/:/opt/selenoid/video/ ` <2> -e OVERRIDE_VIDEO_OUTPUT_DIR=/c/selenoid/video/ ` <3> aerokube/selenoid:latest-release ``` -------------------------------- ### Start Selenoid Docker Container (Windows PowerShell) Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Run Selenoid as a Docker container on Windows using PowerShell. Handles path conversion and volume mounting specific to Windows. ```bash > $current = $PWD -replace "\\", "/" -replace "C", "c" <1> > docker run -d ` --name selenoid ` -p 4444:4444 ` -v //var/run/docker.sock:/var/run/docker.sock ` -v ${current}/config/:/etc/selenoid/:ro ` aerokube/selenoid:latest-release <1> Simple macros to get $PWD with compatible form assumed your directory located on `C:` drive ``` -------------------------------- ### Start Selenoid on Windows without Docker Source: https://github.com/aerokube/selenoid/blob/master/docs/selenoid-without-docker.adoc Launches the Selenoid binary on Windows, disabling Docker and specifying the configuration file. This is used when running browsers directly on the host. ```bash ./selenoid_win_amd64.exe -conf ./browsers.json -disable-docker ``` -------------------------------- ### Docker Command for Selenoid with Video Recording Source: https://github.com/aerokube/selenoid/blob/master/docs/video.adoc Example Docker command to run Selenoid with video recording enabled. Ensure to mount a host directory for video storage and set the OVERRIDE_VIDEO_OUTPUT_DIR environment variable. ```bash $ docker run -d \ --name selenoid \ -p 4444:4444 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /your/directory/config/:/etc/selenoid/:ro \ -v /your/directory/video/:/opt/selenoid/video/ \ -e OVERRIDE_VIDEO_OUTPUT_DIR=/your/directory/video/ \ aerokube/selenoid:latest-release ``` -------------------------------- ### Syslog Docker Logging Configuration for Selenoid Source: https://github.com/aerokube/selenoid/blob/master/docs/logging-configuration-file.adoc Example of a Selenoid logging configuration file using the 'syslog' driver, equivalent to specific Docker logging parameters. ```javascript { "Type" : "syslog", "Config" : { "syslog-address" : "tcp://192.168.0.42:123", "syslog-facility" : "daemon" } } ``` -------------------------------- ### Browser Image Configuration with Locale Source: https://github.com/aerokube/selenoid/blob/master/docs/starting-selenoid-manually.adoc Example of configuring browser images with environment variables for locale settings. This is useful for handling UTF-8 locales and national alphabet symbols. ```json { "chrome": { "default": "64.0", "versions": { "64.0": { "image": "selenoid/chrome:90.0", "...": "", "env" : ["LANG=ru_RU.UTF-8", "LANGUAGE=ru:en", "LC_ALL=ru_RU.UTF-8"] } } } } ``` -------------------------------- ### Get Clipboard Content Source: https://github.com/aerokube/selenoid/blob/master/docs/clipboard.adoc Send an HTTP GET request to retrieve the current value of the browser's clipboard. Requires the session ID. ```bash $ curl http://selenoid-host.example.com:4444/clipboard/f2bcd32b-d932-4cdc-a639-687ab8e4f840 some-clipboard-value ``` -------------------------------- ### Example Selenoid Log File Entry Source: https://github.com/aerokube/selenoid/blob/master/docs/log-files.adoc A typical log file entry from Selenoid, illustrating the timestamp, request counter, status, and other relevant details. ```log 2017/11/01 19:12:38 [-] [NEW_REQUEST] 2017/11/01 19:12:38 [-] [NEW_REQUEST_ACCEPTED] 2017/11/01 19:12:38 [41301] [LOCATING_SERVICE] [firefox-45.0] 2017/11/01 19:12:38 [41301] [USING_DOCKER] [firefox-45.0] 2017/11/01 19:12:38 [41301] [CREATING_CONTAINER] [selenoid/firefox:45.0] 2017/11/01 19:12:38 [41301] [STARTING_CONTAINER] [selenoid/firefox:45.0] [19760edf330a87531eb2109cfbf1bd4b14c739afa08fe133eb1b9813b2ac6c31] 2017/11/01 19:12:39 [41301] [CONTAINER_STARTED] [selenoid/firefox:45.0] [19760edf330a87531eb2109cfbf1bd4b14c739afa08fe133eb1b9813b2ac6c31] [896.680954ms] 2017/11/01 19:12:40 [41301] [SERVICE_STARTED] [selenoid/firefox:45.0] [19760edf330a87531eb2109cfbf1bd4b14c739afa08fe133eb1b9813b2ac6c31] [605.184606ms] 2017/11/01 19:12:40 [41301] [PROXY_TO] [selenoid/firefox:45.0] [19760edf330a87531eb2109cfbf1bd4b14c739afa08fe133eb1b9813b2ac6c31] [http://172.17.0.3:4444/wd/hub] 2017/11/01 19:12:40 [41301] [SESSION_ATTEMPTED] [test-quota] [http://172.17.0.3:4444/wd/hub] [1] 2017/11/01 19:12:42 [41301] [SESSION_CREATED] [test-quota] [345bb886-7026-46d7-82d4-4788c0460110] [http://172.17.0.3:4444/wd/hub] [1] [4.155712239s] .... 2017/11/01 19:14:30 [SESSION_DELETED] [345bb886-7026-46d7-82d4-4788c0460110] ``` -------------------------------- ### Pulling a Browser Image Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc Use this command to pull a specific browser version's container image. Ensure you have Docker installed and running. ```bash $ docker pull selenoid/chrome:62.0 ``` -------------------------------- ### Get Selenoid Status Source: https://github.com/aerokube/selenoid/blob/master/docs/usage-statistics.adoc Retrieve the current usage statistics from Selenoid using a simple curl command. ```bash $ curl http://localhost:4444/status ``` -------------------------------- ### Generate Telegraf Configuration Source: https://github.com/aerokube/selenoid/blob/master/docs/usage-statistics.adoc Generate a base Telegraf configuration file using the httpjson input and graphite output plugins. This command should be run on the host where Telegraf will be installed. ```bash # mkdir -p /etc/telegraf # docker run --rm telegraf:alpine \ --input-filter httpjson \ --output-filter graphite config > /etc/telegraf/telegraf.conf ``` -------------------------------- ### Example Metric Names Source: https://github.com/aerokube/selenoid/blob/master/docs/usage-statistics.adoc Illustrative metric names that will be sent to the Graphite server after Telegraf is configured and running. These names reflect the host, input plugin, and specific metric from Selenoid. ```text one_min.selenoid_example_com.httpjson_selenoid.pending one_min.selenoid_example_com.httpjson_selenoid.queued one_min.selenoid_example_com.httpjson_selenoid.total ``` -------------------------------- ### Shell Command to Remove Old Video Files Source: https://github.com/aerokube/selenoid/blob/master/docs/video.adoc Example shell command for Unix-like systems to remove video files older than a specified duration (e.g., 2 hours). This helps manage storage space. ```bash $ find /path/to/video/dir -mindepth 1 -maxdepth 1 -mmin +120 -name '*.mp4' | xargs rm -rf ``` -------------------------------- ### Download a File via Selenoid API Source: https://github.com/aerokube/selenoid/blob/master/docs/file-download.adoc Access downloaded files from a running browser session using an HTTP GET request to the /download endpoint. This requires an HTTP file server listening on port 8080 within the browser container. ```http GET http://selenoid-host.example.com:4444/download/f2bcd32b-d932-4cdc-a639-687ab8e4f840/myfile.txt ``` -------------------------------- ### Get Clipboard Value Source: https://github.com/aerokube/selenoid/blob/master/docs/clipboard.adoc Retrieves the current value of the browser clipboard. This is useful for verifying copy-paste functionality within your application. ```APIDOC ## GET /clipboard/{sessionId} ### Description Retrieves the current value of the browser clipboard for a given session. ### Method GET ### Endpoint /clipboard/{sessionId} ### Parameters #### Path Parameters - **sessionId** (string) - Required - The ID of the browser session. ### Response #### Success Response (200) - The response body contains the clipboard value as plain text. ### Response Example ``` some-clipboard-value ``` ``` -------------------------------- ### Build Selenoid from Source Source: https://github.com/aerokube/selenoid/blob/master/docs/contributing.adoc Builds the Selenoid executable from its source code. Ensure Golang 1.12+ and GOPATH are set up correctly. ```bash git clone https://github.com/aerokube/selenoid.git cd selenoid go build ``` -------------------------------- ### Selenoid Configuration within Docker Source: https://github.com/aerokube/selenoid/blob/master/docs/cli-flags.adoc Shows how to run Selenoid as a Docker container, mapping ports, volumes, and passing configuration flags for browser settings, container limits, and video output. ```bash # docker run -d --name selenoid \ -p 4444:4444 \ -v ~/.aerokube/selenoid/:/etc/selenoid/:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ aerokube/selenoid:latest-release \ -conf /etc/selenoid/browsers.json -limit 10 -video-output-dir /opt/selenoid/video/ ``` -------------------------------- ### Run Selenoid Source: https://github.com/aerokube/selenoid/blob/master/docs/contributing.adoc Executes the Selenoid binary with help information displayed. This is typically run after building the source. ```bash ./selenoid --help ``` -------------------------------- ### Make cm Binary Executable Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc On Linux or Mac, grant execution permissions to the downloaded Configuration Manager binary. ```bash $ chmod +x cm ``` -------------------------------- ### Generate Documentation Locally Source: https://github.com/aerokube/selenoid/blob/master/docs/contributing.adoc Generates the project's documentation locally using Docker and Asciidoctor. It mounts the local docs directory to the container for processing. ```bash docker run --rm -v ./docs/:/documents/ \ asciidoctor/docker-asciidoctor \ asciidoctor -D /documents/output/ index.adoc ``` -------------------------------- ### Enable Live Browser Screen with VNC Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Enable VNC server in the container to view the browser screen during test execution. Access the stream via Selenoid UI. ```yaml enableVNC: true ``` -------------------------------- ### Configure Selenoid for S3 Uploads Source: https://github.com/aerokube/selenoid/blob/master/docs/s3.adoc Launch Selenoid with command-line flags to specify S3 endpoint, region, bucket name, and access credentials. Environment variables and shared credentials file are used as fallbacks if keys are omitted. ```bash ./selenoid -s3-endpoint https://s3.us-east-2.amazonaws.com -s3-region us-east-2 -s3-bucket-name my-bucket -s3-access-key -s3-secret-key ``` -------------------------------- ### Using Standalone Binary Configuration Source: https://github.com/aerokube/selenoid/blob/master/docs/browsers-configuration-file.adoc Specifies how to configure Selenoid to use a standalone binary instead of a Docker container by providing the command in the 'image' field. ```javascript "46.0": { "image": ["/usr/bin/mybinary", "-arg1", "foo", "-arg2", "bar", "-arg3"], "port": "4444" } ``` -------------------------------- ### Build Selenoid Docker Container Source: https://github.com/aerokube/selenoid/blob/master/docs/contributing.adoc Creates a Docker container for Selenoid, specifically for Linux amd64 architecture. This command first builds a static binary and then uses Docker buildx to create the image. ```bash mkdir -p dist GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o dist/selenoid_linux_amd64 docker buildx build --pull --platform linux/amd64 -t selenoid:latest . ``` -------------------------------- ### Enable Video Recording Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Enable video recording for a test session. Custom video names, screen sizes, frame rates, and codecs can also be specified. ```yaml enableVideo: true ``` -------------------------------- ### Uploading Files with Python Source: https://github.com/aerokube/selenoid/blob/master/docs/file-upload.adoc This Python snippet demonstrates file uploads. It requires importing LocalFileDetector and setting the file detector on the driver instance before sending keys to the file input element. ```python from selenium.webdriver.remote.file_detector import LocalFileDetector # ... input = driver.find_element_by_css_selector("input[type='file']") driver.execute_script("arguments[0].style.display = 'block';", input) driver.file_detector = LocalFileDetector() input.send_keys("/path/to/file/on/machine/which/runs/tests") ``` -------------------------------- ### List All Available Log Files Source: https://github.com/aerokube/selenoid/blob/master/docs/logs.adoc Retrieve a list of all available log files by accessing the /logs/ endpoint. ```http http://selenoid-host.example.com:4444/logs/ ``` -------------------------------- ### Advanced Optional Fields for Browser Configuration Source: https://github.com/aerokube/selenoid/blob/master/docs/browsers-configuration-file.adoc Illustrates the use of various optional fields for fine-tuning browser container settings, including tmpfs, volumes, environment variables, and hosts. ```javascript "46.0": { //... "port": "", "tmpfs": {"/tmp": "size=512m", "/var": "size=128m"}, "path" : "", "volumes": ["/from:/to", "/another:/one:ro"], "env" : ["TZ=Europe/Moscow", "ONE_MORE_VARIABLE=itsValue"], "hosts" : ["one.example.com:192.168.0.1", "two.example.com:192.168.0.2"], "labels" : {"component": "frontend", "project": "my-project"}, "sysctl" : {"net.ipv4.tcp_timestamps": "2", "kern.maxprocperuid": "1000"}, "shmSize" : 268435456 } ``` -------------------------------- ### Basic Selenoid Logging Configuration Structure Source: https://github.com/aerokube/selenoid/blob/master/docs/logging-configuration-file.adoc Defines the structure for a Selenoid logging configuration file, specifying the Docker logging driver type and its configuration parameters. ```javascript { "Type" : "", "Config" : { "key1" : "value1", "key2" : "value2" } } ``` -------------------------------- ### Docker Command to Enable Logs Source: https://github.com/aerokube/selenoid/blob/master/docs/logs.adoc When running Selenoid in Docker, mount a host directory to the container's log path and use the -log-output-dir flag pointing to the container path. ```bash $ docker run -d --name selenoid \ -p 4444:4444 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /your/directory/config/:/etc/selenoid/:ro \ -v /your/directory/logs/:/opt/selenoid/logs/ \ aerokube/selenoid:latest-release -log-output-dir /opt/selenoid/logs ``` -------------------------------- ### Configure Chrome for File Downloads (Java) Source: https://github.com/aerokube/selenoid/blob/master/docs/file-download.adoc Set Chrome options to disable download prompts, specify a download directory, and handle PDF viewing preferences. Use this when you need to automate file downloads in Chrome. ```java ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption("prefs", new HashMap(){ { put("profile.default_content_settings.popups", 0); put("download.default_directory", "/home/selenium/Downloads"); put("download.prompt_for_download", false); put("download.directory_upgrade", true); put("safebrowsing.enabled", false); put("plugins.always_open_pdf_externally", true); put("plugins.plugins_disabled", new ArrayList(){ { add("Chrome PDF Viewer"); } }); } }); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), chromeOptions); driver.navigate().to("http://example.com/myfile.odt"); ``` -------------------------------- ### View Selenoid Docker Container Logs Source: https://github.com/aerokube/selenoid/blob/master/docs/faq.adoc Use the `docker logs` command to view the standard output logs from a running Selenoid Docker container. Add the `-f` flag to follow the logs in real-time. ```bash docker logs selenoid ``` ```bash docker logs -f selenoid ``` -------------------------------- ### Pass Capabilities via Protocol Extensions Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Use the 'selenoid:options' key to pass capabilities when Selenium clients have limitations on supported capabilities. This delivers the same result as passing capabilities normally. ```json {"browserName": "firefox", "version": "57.0", "selenoid:options": {"screenResolution": "1280x1024x24"}} ``` -------------------------------- ### Build Selenoid with S3 Support Source: https://github.com/aerokube/selenoid/blob/master/docs/s3.adoc Compile Selenoid with the 's3' build tag to enable S3 upload functionality. This is required before configuring S3 settings. ```bash go build -tags s3 ``` -------------------------------- ### Enable Log Output Directory Source: https://github.com/aerokube/selenoid/blob/master/docs/logs.adoc Use the -log-output-dir flag to specify the directory where Selenoid will save session log files. ```bash $ ./selenoid -log-output-dir /path/to/some/dir ``` -------------------------------- ### S3 CLI Flags for Selenoid Source: https://github.com/aerokube/selenoid/blob/master/docs/cli-flags.adoc Lists the command-line flags available for Selenoid when compiled with S3 support, used for configuring S3 access, bucket details, and file handling. ```bash -s3-access-key string S3 access key -s3-bucket-name string S3 bucket name -s3-endpoint string S3 endpoint URL -s3-exclude-files string Pattern used to match and exclude files -s3-force-path-style Force path-style addressing for file upload -s3-include-files string Pattern used to match and include files -s3-keep-files Do not remove uploaded files -s3-key-pattern string S3 bucket name (default "$fileName") -s3-reduced-redundancy Use reduced redundancy storage class -s3-region string S3 region -s3-secret-key string S3 secret key ``` -------------------------------- ### Update Selenoid and Browsers (Short Way) Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc This command automates downloading the latest Selenoid release, browser images, generating a new browsers.json, and restarting Selenoid. It's suitable for personal usage as it interrupts running sessions. ```bash $ ./cm selenoid update ``` -------------------------------- ### Selenoid Docker Compose (Default Network) Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-compose.adoc Use this configuration to run Selenoid within the default Docker network. Ensure the necessary configuration directories are created beforehand. ```yaml version: '3' services: selenoid: network_mode: bridge image: aerokube/selenoid:latest-release volumes: - "/path/to/config:/etc/selenoid" - "/var/run/docker.sock:/var/run/docker.sock" - "/path/to/config/video:/opt/selenoid/video" - "/path/to/config/logs:/opt/selenoid/logs" environment: - OVERRIDE_VIDEO_OUTPUT_DIR=/path/to/config/video command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs"] ports: - "4444:4444" ``` -------------------------------- ### Set Custom Video Screen Size Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Specify a custom screen size for video recording. If smaller than the actual screen, the video will be trimmed from the top-left corner. ```yaml videoScreenSize: "1024x768" ``` -------------------------------- ### Reload Configuration with SIGHUP Source: https://github.com/aerokube/selenoid/blob/master/docs/reloading-configuration.adoc Send a SIGHUP signal to the Selenoid process to reload its configuration. Use either the standard kill command with the process ID (PID) or the docker kill command with the container ID or name. Ensure only one command is used. ```bash # kill -HUP # docker kill -s HUP ``` -------------------------------- ### Configure Hosts Entries Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Add custom entries to the /etc/hosts file for browser images. These entries override those from the browser configuration file if hosts are the same. ```yaml hostsEntries: ["example.com:192.168.0.1", "test.com:192.168.0.2"] ``` -------------------------------- ### Basic browsers.json Structure Source: https://github.com/aerokube/selenoid/blob/master/docs/browsers-configuration-file.adoc Defines the fundamental structure for configuring browsers, including default versions and specific version details like image, port, and volumes. ```javascript { "firefox": { "default": "46.0", "versions": { "46.0": { "image": "selenoid/firefox:46.0", "port": "4444", "tmpfs": {"/tmp": "size=512m"}, "path" : "/wd/hub", "volumes" : ["/from:/to:ro"], "env" : ["TZ=Europe/Moscow"], "hosts" : ["example.com:192.168.0.1"], "shmSize" : 268435456, "cpu" : "1.0", "mem" : "512m" }, "50.0" :{ // ... } } }, "chrome": { // ... } } ``` -------------------------------- ### Listing All Available Video Files Source: https://github.com/aerokube/selenoid/blob/master/docs/video.adoc URL to list all available recorded video files. This can be used to check which videos are currently stored on the Selenoid host. ```http http://selenoid-host.example.com:4444/video/ ``` -------------------------------- ### Pass Capabilities Normally Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Standard way to pass browser capabilities, including browser name, version, and screen resolution. ```json {"browserName": "firefox", "version": "57.0", "screenResolution": "1280x1024x24"} ``` -------------------------------- ### Add User to Docker Group (Linux) Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc On Linux, to grant permissions to access Docker, add your user to the 'docker' group. This is a recommended step to avoid running Selenoid with sudo. ```bash $ sudo usermod -aG docker $USER ``` -------------------------------- ### Pull Telegraf Docker Image Source: https://github.com/aerokube/selenoid/blob/master/docs/usage-statistics.adoc Download the latest Telegraf Alpine Docker image. This is the first step in setting up Telegraf to collect and send Selenoid statistics. ```bash # docker pull telegraf:alpine ``` -------------------------------- ### Specify Configuration File Path for Selenoid in Docker Source: https://github.com/aerokube/selenoid/blob/master/docs/faq.adoc When running Selenoid in a Docker container with custom arguments, explicitly specify the path to the configuration file using the `-conf` flag if it's not automatically handled. ```bash docker run aerokube/selenoid:some-version -limit 10 -conf /etc/selenoid/browsers.json ``` -------------------------------- ### Update Selenoid with VNC Support Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc Adds the --vnc flag to download browser images that include VNC support. This is a variation of the automated update process. ```bash $ ./cm selenoid update --vnc ``` -------------------------------- ### Google Analytics and Yandex.Metrica Initialization Source: https://github.com/aerokube/selenoid/blob/master/docs/docinfo-footer.html This snippet initializes Google Analytics and Yandex.Metrica for website tracking. It should be placed in the head of your HTML document. ```javascript window.dataLayer = window.dataLayer || []; function gtag(){ dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'UA-23854888-2'); (function(m,e,t,r,i,k,a){ m[i]=m[i]||function(){ (m[i].a=m[i].a||[]).push(arguments) }; m[i].l=1*new Date(); k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a) })(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(43539754, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true, trackHash:true }); ``` -------------------------------- ### Selenoid Docker Compose (Custom Network) Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-compose.adoc This configuration runs Selenoid in a custom Docker network. It requires creating the network beforehand and specifying the network name using the -container-network flag. ```yaml version: '3' networks: selenoid: external: true # This assumes network is already created services: selenoid: networks: selenoid: null image: aerokube/selenoid:latest-release volumes: - "/path/to/config:/etc/selenoid" - "/var/run/docker.sock:/var/run/docker.sock" - "/path/to/config/video:/opt/selenoid/video" - "/path/to/config/logs:/opt/selenoid/logs" environment: - OVERRIDE_VIDEO_OUTPUT_DIR=/path/to/config/video command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs", "-container-network", "selenoid"] ports: - "4444:4444" ``` -------------------------------- ### Set Custom Video Codec Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Specify a different codec for video output if the default 'libx264' consumes too much CPU. Refer to FFmpeg for supported values. ```yaml videoCodec: "mpeg4" ``` -------------------------------- ### Troubleshoot Selenoid Video Recording Errors Source: https://github.com/aerokube/selenoid/blob/master/docs/faq.adoc This log message indicates a potential misconfiguration with Selenoid's video recording feature. Ensure the OVERRIDE_VIDEO_OUTPUT_DIR environment variable is correctly set and that host machine video directories are mounted properly when using custom arguments. ```log 2018/03/20 21:06:37 [9] [VIDEO_ERROR] [Failed to rename /video/selenoid607667f7e1c7923779e35506b040300d.mp4 to /video/8019c4bc-9bec-4a8b-aa40-68d1db0cffd2.mp4: rename /video/selenoid607667f7e1c7923779e35506b040300d.mp4 /video/8019c4bc-9bec-4a8b-aa40-68d1db0cffd2.mp4: no such file or directory] ``` -------------------------------- ### Configure docker0 MAC Address Permanently Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-settings.adoc Add this configuration to `/etc/network/interfaces` to ensure the docker0 MAC address is set persistently across reboots. ```bash iface docker0 inet static # ... the rest of lines post-up ip link set docker0 address 00:25:90:eb:fb:3e ``` -------------------------------- ### Enable Session Log Saving Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Enable saving logs for a test session. Custom log file names can also be specified. ```yaml enableLog: true ``` -------------------------------- ### Update Selenoid with Specific Number of Last Versions Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc Specifies the total number of the last browser versions to download using the --last-versions flag. The default is 2. ```bash $ ./cm selenoid update --last-versions 5 ``` -------------------------------- ### Check Docker Storage Driver Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-settings.adoc Use this command to identify the currently active Docker storage driver on your system. ```bash # docker info | grep Storage ``` -------------------------------- ### Uploading Files with Java Source: https://github.com/aerokube/selenoid/blob/master/docs/file-upload.adoc Use this snippet to upload files using Java. Ensure your Selenium client is configured with LocalFileDetector and the file path points to the machine running the tests. ```java // Find file input element WebElement input = driver.findElement(By.cssSelector("input[type='file']")); // Make sure element is visible ((JavascriptExecutor) driver).executeScript("arguments[0].style.display = 'block';", input); // Configure your client to upload local files to remote Selenium instance driver.setFileDetector(new LocalFileDetector()); // Specify you local file path here (not path inside browser container!) input.sendKeys("/path/to/file/on/machine/which/runs/tests"); ``` -------------------------------- ### Set Docker API Version for Selenoid Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-settings.adoc When encountering client/server API version mismatches, set the DOCKER_API_VERSION environment variable to align them. ```bash # docker run -e DOCKER_API_VERSION=1.24 -d --name selenoid -p 4444:4444 -v /etc/selenoid:/etc/selenoid:ro -v /var/run/docker.sock:/var/run/docker.sock aerokube/selenoid:latest-release ``` -------------------------------- ### Selenoid UI Default URL Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc Navigate to this URL in your browser to access the Selenoid UI. ```text http://localhost:8080/ ``` -------------------------------- ### Configure Firefox for File Downloads (Java) Source: https://github.com/aerokube/selenoid/blob/master/docs/file-download.adoc Set Firefox capabilities to automatically save downloaded files of type 'application/octet-stream' without prompting. Use this for automating file downloads in Firefox. ```java FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setCapability("moz:firefoxOptions", new HashMap(){ { put("prefs", new HashMap(){ { put("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream"); } }); } }); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), firefoxOptions); driver.navigate().to("http://example.com/myfile.odt"); ``` -------------------------------- ### Configure Telegraf for Selenoid Statistics Source: https://github.com/aerokube/selenoid/blob/master/docs/usage-statistics.adoc Edit the Telegraf configuration file to specify the interval for collecting statistics, the Graphite server details, and the URL for the Selenoid status endpoint. ```go [agent] interval = "10s" <1> [[outputs.graphite]] servers = ["my-graphite-host.example.com:2024"] <2> prefix = "one_min" <3> template = "host.measurement.field" [[inputs.httpjson]] name = "selenoid" servers = [ "http://localhost:4444/status" <4> ] ``` -------------------------------- ### Configure Selenoid Without Restart Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc This command pulls new images and regenerates the configuration without restarting Selenoid. It allows for updates while keeping existing sessions active. ```bash $ ./cm selenoid configure --vnc --last-versions 5 ``` -------------------------------- ### Direct Link to Download Log File Source: https://github.com/aerokube/selenoid/blob/master/docs/logs.adoc Access saved log files using the /logs/.log endpoint. This link is only active after the session has finished. ```http http://selenoid-host.example.com:4444/logs/.log ``` -------------------------------- ### Set Custom Video Name Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Provide a custom name for the recorded video file. Ensure the name includes the '.mp4' extension. ```yaml videoName: "my-cool-video.mp4" ``` -------------------------------- ### Set Custom Log File Name Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Provide a custom name for the saved log file. Ensure the name includes the '.log' extension. ```yaml logName: "my-cool-log.log" ``` -------------------------------- ### Selenoid Tests Endpoint Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc Configure your tests to run against this endpoint, similar to a regular Selenium hub. ```text http://localhost:4444/wd/hub ``` -------------------------------- ### Selenoid Capabilities for Internet Explorer Source: https://github.com/aerokube/selenoid/blob/master/docs/selenoid-without-docker.adoc Specifies the browser name and version required to initiate an Internet Explorer session through Selenoid. ```capabilities browserName = internet explorer version = 11 ``` -------------------------------- ### Set Container Labels Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Pass additional metadata to browser sessions, such as environment or build information. These labels can be used to enrich session logs for better searchability. ```yaml labels: {"environment": "testing", "build-number": "14353"} ``` -------------------------------- ### Set Environment Variables Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Append environment variables to browser containers. These are added to variables from the configuration file. ```yaml env: ["LANG=ru_RU.UTF-8", "LANGUAGE=ru:en", "LC_ALL=ru_RU.UTF-8"] ``` -------------------------------- ### Select Android Emulator Skin Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Select a specific emulator skin for Android containers. You can specify a predefined skin name or a custom screen resolution. ```yaml skin: "WXGA720" ``` ```yaml skin: "720x1280" ``` -------------------------------- ### Uploading Files with Webdriver.io Source: https://github.com/aerokube/selenoid/blob/master/docs/file-upload.adoc Use this Webdriver.io snippet for file uploads. It involves specifying the local file path, uploading it to the remote Selenium instance using browser.uploadFile, and then setting the value of the file input element. ```javascript var filePath = path.join('/path/to/file/on/machine/which/runs/tests'); var remoteFilePath = browser.uploadFile(filePath); $("input[type='file']").setValue(remoteFilePath); ``` -------------------------------- ### Extract and Pull Browser Images using jq Source: https://github.com/aerokube/selenoid/blob/master/docs/browsers-configuration-file.adoc This command extracts image names from a browsers.json file and uses docker pull to fetch them. It's useful for updating browser images in a running cluster without downtime. ```bash # cat /path/to/browsers.json | jq -r '..|.image?|strings' | xargs -I{} docker pull {} ``` -------------------------------- ### Selenoid Status URL Source: https://github.com/aerokube/selenoid/blob/master/docs/quick-start-guide.adoc Check if Selenoid is running by accessing this status URL. A successful request returns JSON with browser usage statistics. ```text http://localhost:4444/status ``` -------------------------------- ### Check Selenoid Instance Health Source: https://github.com/aerokube/selenoid/blob/master/docs/reloading-configuration.adoc Use the curl command to send a request to the /ping endpoint of the Selenoid instance. This is used to verify if Selenoid is operating normally. ```bash $ curl -s http://example.com:4444/ping ``` -------------------------------- ### Set Custom Screen Resolution Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Specify a custom screen resolution for the browser container. Note that this affects the screen, not the browser window size, and 'maximize' operation is not supported. ```yaml screenResolution: "1280x1024x24" ``` -------------------------------- ### Reload Selenoid Configuration Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc This command reloads Selenoid's configuration without restarting the service, which is recommended for production environments. It sends a HUP signal to the Selenoid process. ```bash $ docker kill -s HUP selenoid ``` -------------------------------- ### Link Application Containers Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Link browser containers to application containers running on the same host. Allows using custom URLs in tests. ```yaml applicationContainers: ["spring-application-main:my-cool-app", "spring-application-gateway"] ``` -------------------------------- ### Selenoid browsers.json for Internet Explorer Source: https://github.com/aerokube/selenoid/blob/master/docs/selenoid-without-docker.adoc Defines the 'internet explorer' browser with version '11', specifying the path to the IEDriverServer executable and enabling debug logging. ```json { "internet explorer": { "default": "11", "versions": { "11": { "image": ["C:\\IEDriverServer.exe", "--log-level=DEBUG"] } } } } ``` -------------------------------- ### Set Custom Video Frame Rate Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Change the frame rate for video recording. The default is 12 frames per second. ```yaml videoFrameRate: 24 ``` -------------------------------- ### Update Clipboard Content Source: https://github.com/aerokube/selenoid/blob/master/docs/clipboard.adoc Send an HTTP POST request with the desired value in the request body to update the browser's clipboard. Requires the session ID. ```bash $ curl -X POST --data 'some-clipboard-value' http://selenoid-host.example.com:4444/clipboard/f2bcd32b-d932-4cdc-a639-687ab8e4f840 ``` -------------------------------- ### Set docker0 MAC Address Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-settings.adoc Manually set the MAC address for the docker0 interface to match eth0 to improve bridged networking performance. ```bash # ip link set docker0 address 00:25:90:eb:fb:3e ``` -------------------------------- ### Pull Video Recorder Image Source: https://github.com/aerokube/selenoid/blob/master/docs/video.adoc Pull the video recorder image once before using the video recording feature. This image contains the necessary software for capturing browser screen recordings. ```bash $ docker pull selenoid/video-recorder:latest-release ``` -------------------------------- ### Check Selenoid Health and Reload Status Source: https://github.com/aerokube/selenoid/blob/master/docs/updating-browsers.adoc Verifies that the Selenoid configuration has been reloaded successfully by checking the 'lastReloadTime' field in the ping response. This is useful for confirming updates in production. ```bash $ curl -s http://example.com:4444/ping {"uptime":"","lastReloadTime":"2017-05-12 12:33:06.322038542 +0300 MSK","numRequests":} ``` -------------------------------- ### Add Additional Docker Networks Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Connect browser containers to additional Docker networks. This is necessary if your application is running in a network other than the default Selenoid network. ```yaml additionalNetworks: ["my-custom-net-1", "my-custom-net-2"] ``` -------------------------------- ### Limit Container Memory Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-settings.adoc Use the -mem flag to specify the maximum memory a container can consume, using Docker's format. ```bash # ./selenoid -mem 128m ``` -------------------------------- ### Set Per-Session Environment Variables Source: https://github.com/aerokube/selenoid/blob/master/docs/special-capabilities.adoc Set environment variables for individual test cases, useful for configuring default locales or other test-specific settings. ```yaml env ``` -------------------------------- ### Set Docker API Version for Selenoid Docker Container Source: https://github.com/aerokube/selenoid/blob/master/docs/faq.adoc When running Selenoid as a Docker container, set the `DOCKER_API_VERSION` environment variable using the `-e` flag to match your Docker API version. ```bash docker run -e DOCKER_API_VERSION=1.32 aerokube/selenoid:some-version ``` -------------------------------- ### Accessing Recorded Video Files Source: https://github.com/aerokube/selenoid/blob/master/docs/video.adoc Direct link to access a specific recorded video file. The link is only valid after the session has finished and the file has been renamed. ```http http://selenoid-host.example.com:4444/video/.mp4 ``` -------------------------------- ### Limit Container CPU Usage Source: https://github.com/aerokube/selenoid/blob/master/docs/docker-settings.adoc Use the -cpu flag to set the maximum number of CPUs a container can utilize, specified as a float. ```bash # ./selenoid -cpu 1.5 ```