Commands This section contains the APIs related to browsing context commands. Open a new window Creates a new browsing context in a new window. Java Ruby JavaScript Kotlin Selenium v4.8 void testCreateAWindow() { BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.WINDOW); Assertions.assertNotNull(browsingContext.getId()); } View Complete Code View on GitHub /examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java Copy Close package ...| Selenium
CAPTCHA, short for Completely Automated Public Turing test to tell Computers and Humans Apart, is explicitly designed to prevent automation, so do not try! There are two primary strategies to get around CAPTCHA checks: Disable CAPTCHAs in your test environment Add a hook to allow tests to bypass the CAPTCHA| Selenium
Building a test suite using WebDriver will require you to understand and effectively use several components. As with everything in software, different people use different terms for the same idea. Below is a breakdown of how terms are used in this description. Terminology API: Application Programming Interface. This is the set of “commands” you use to manipulate WebDriver. Library: A code module that contains the APIs and the code necessary to implement them.| Selenium
The Documentation of Selenium Every effort has been made to make this documentation as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as-is” basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained herein. No patent liability is assumed with respect to the use of the information contained herein.| Selenium
(previously located: https://github.com/SeleniumHQ/selenium/wiki/Bot-Style-Tests) Overview Over time, projects tend to accumulate large numbers of tests. As the total number of tests increases, it becomes harder to make changes to the codebase — a single “simple” change may cause numerous tests to fail, even though the application still works properly. Sometimes these problems are unavoidable, but when they do occur you want to be up and running again as quickly as possible. The followi...| Selenium
Expected Conditions are used with Explicit Waits. Instead of defining the block of code to be executed with a lambda, an expected conditions method can be created to represent common things that get waited on. Some methods take locators as arguments, others take elements as arguments. These methods can include conditions such as: element exists element is stale element is visible text is visible title contains specified value Java Python CSharp Ruby JavaScript Kotlin Expected Conditions Docum...| Selenium
Because Selenium cannot interact with the file upload dialog, it provides a way to upload files without opening the dialog. If the element is an input element with type file, you can use the send keys method to send the full path to the file that will be uploaded. Java Python CSharp Ruby JavaScript Kotlin WebElement fileInput = driver.findElement(By.cssSelector("input[type=file]")); fileInput.sendKeys(uploadFile.getAbsolutePath()); driver.findElement(By.id("file-submit")).click(); View Comple...| Selenium
The help commands display information based on the current code implementation. Hence, it will provide accurate information in case the documentation is not updated. It is the easiest way to learn about Grid 4 configuration for any new version. Info Command The info command provides detailed docs on the following topics: Configuring Selenium Security Session Map setup Tracing Config help Quick config help and overview is provided by running:| Selenium
This section contains the APIs related to input commands. Perform Actions Java Ruby JavaScript Kotlin Selenium v4.17 Actions selectThreeOptions = actions.click(options.get(1)).keyDown(Keys.SHIFT).click(options.get(3)).keyUp(Keys.SHIFT); input.perform(windowHandle, selectThreeOptions.getSequences()); View Complete Code View on GitHub /examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/ActionsTest.java Copy Close package dev.selenium.bidirectional.webdriver_bidi; import dev.s...| Selenium
A locator is a way to identify elements on a page. It is the argument passed to the Finding element methods. Check out our encouraged test practices for tips on locators, including which to use when and why to declare locators separately from the finding methods. Traditional Locators Selenium provides support for these 8 traditional location strategies in WebDriver: Locator Description class name Locates elements whose class name contains the search value (compound class names are not permitt...| Selenium
This section contains the APIs related to logging. Console logs Listen to the console.log events and register callbacks to process the event. Java Ruby JavaScript Kotlin Selenium v4.8 CompletableFuture<ConsoleLogEntry> future = new CompletableFuture<>(); logInspector.onConsoleEntry(future::complete); driver.get("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); driver.findElement(By.id("consoleLog")).click(); ConsoleLogEntry logEntry = future.get(5, TimeUnit.SECONDS); View Comp...| Selenium
Remember that to use WebDriver BiDi, you must enable it in Options. For more details, see Enabling BiDi Console Message Handlers Record or take actions on console.log events. Add Handler Java Python CSharp Ruby JavaScript Kotlin Implementation Missing driver.script.add_console_message_handler(log_entries.append) View Complete Code View on GitHub /examples/python/tests/bidi/test_bidi_logging.py Copy Close import pytest from selenium.webdriver.common.by import By from selenium.webdriver.support...| Selenium
Navigate to The first thing you will want to do after launching a browser is to open your website. This can be achieved in a single line: Java Python CSharp Ruby JavaScript Kotlin //Convenient driver.get("https://selenium.dev"); //Longer way driver.navigate().to("https://selenium.dev"); View Complete Code View on GitHub examples/java/src/test/java/dev/selenium/interactions/NavigationTest.java Copy Close package dev.selenium.interactions; import org.junit.jupiter.api.Test; import org.openqa.se...| Selenium
The implementation of these features is being tracked here: #13993 Remember that to use WebDriver BiDi, you must enable it in Options. For more details, see Enabling BiDi Authentication Handlers Request Handlers Response Handlers| Selenium
Commands This section contains the APIs related to network commands. Add network intercept Java Ruby JavaScript Kotlin Selenium v4.18 try (Network network = new Network(driver)) { String intercept = network.addIntercept(new AddInterceptParameters(InterceptPhase.BEFORE_REQUEST_SENT)); View Complete Code View on GitHub /examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/NetworkCommandsTest.java Copy Close package dev.selenium.bidirectional.webdriver_bidi; import dev.selenium....| Selenium
First, start by asking yourself whether or not you really need to use a browser. Odds are that, at some point, if you are working on a complex web application, you will need to open a browser and actually test it. Functional end-user tests such as Selenium tests are expensive to run, however. Furthermore, they typically require substantial infrastructure to be in place to be run effectively. It is a good rule to always ask yourself if what you want to test can be done using more lightweight t...| Selenium
The implementation of these features is being tracked here: #13992 Remember that to use WebDriver BiDi, you must enable it in Options. For more details, see Enabling BiDi Script Pinning Execute Script DOM Mutation Handlers| Selenium
Commands This section contains the APIs related to script commands. Call function in a browsing context Java Ruby JavaScript Kotlin Selenium v4.15 try (Script script = new Script(id, driver)) { List<LocalValue> arguments = new ArrayList<>(); arguments.add(PrimitiveProtocolValue.numberValue(22)); Map<Object, LocalValue> value = new HashMap<>(); value.put("some_property", LocalValue.numberValue(42)); LocalValue thisParameter = LocalValue.objectValue(value); arguments.add(thisParameter); Evaluat...| Selenium
WebDriver provides an API for working with the three types of native popup messages offered by JavaScript. These popups are styled by the browser and offer limited customisation. Alerts The simplest of these is referred to as an alert, which shows a custom message, and a single button which dismisses the alert, labelled in most browsers as OK. It can also be dismissed in most browsers by pressing the close button, but this will always do the same thing as the OK button.| Selenium
Different sections are available to configure a Grid. Each section has options can be configured through command line arguments. A complete description of the component to section mapping can be seen below. Note that this documentation could be outdated if an option was modified or added but has not been documented yet. In case you bump into this situation, please check the “Config help” section and feel free to send us a pull request updating this page.| Selenium
Selenium is a big software project, its site and documentation are key to understanding how things work and learning effective ways to exploit its potential. This project contains both Selenium’s site and documentation. This is an ongoing effort (not targeted at any specific release) to provide updated information on how to use Selenium effectively, how to get involved and how to contribute to Selenium. Contributions toward the site and docs follow the process described in the below section...| Selenium
This documentation previously located on the wiki WebDriver is a large project: if we tried to push everything into a single monolithic build file it eventually becomes unmanageable. We know this. We’ve tried it. So we broke the single Rakefile into a series of build.desc files. Each of these describe a part of the build. Let’s take a look at a build.desc file. This is part of the main test build.| Selenium
Selenium controls web browsers Selenium is many things but at its core, it is a toolset for web browser automation that uses the best techniques available to remotely control browser instances and emulate a user’s interaction with the browser. Selenium allows users to simulate common activities performed by end-users; entering text into fields, selecting drop-down values and checking boxes, and clicking links in documents. It also provides many other controls such as mouse movement, arbitra...| Selenium
Whilst it is possible to start a download by clicking a link with a browser under Selenium’s control, the API does not expose download progress, making it less than ideal for testing downloaded files. This is because downloading files is not considered an important aspect of emulating user interaction with the web platform. Instead, find the link using Selenium (and any required cookies) and pass it to a HTTP request library like libcurl.| Selenium
One of the most fundamental aspects of using Selenium is obtaining element references to work with. Selenium offers a number of built-in locator strategies to uniquely identify an element. There are many ways to use the locators in very advanced scenarios. For the purposes of this documentation, let’s consider this HTML snippet: <ol id="vegetables"> <li class="potatoes">… <li class="onions">… <li class="tomatoes"><span>Tomato is a Vegetable</span>… </ol> <ul id="fruits"> <li class="ba...| Selenium
Quick start Prerequisites Java 11 or higher installed Browser(s) installed Browser driver(s) Selenium Manager will configure the drivers automatically if you add --selenium-manager true. Installed and on the PATH Download the Selenium Server jar file from the latest release Start the Grid java -jar selenium-server-<version>.jar standalone Point* your WebDriver tests to http://localhost:4444 (Optional) Check running tests and available capabilities by opening your browser at http://localhost:4...| Selenium
GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. It gives users the power to ask for exactly what they need and nothing more. Enums Enums represent possible sets of values for a field. For example, the Node object has a field called status. The state is an enum (specifically, of type Status) because it may be UP , DRAINING or UNAVAILABLE.| Selenium
You can read our documentation for more information about Grid 4 Selenium Grid is a smart proxy server that allows Selenium tests to route commands to remote web browser instances. Its aim is to provide an easy way to run tests in parallel on multiple machines. With Selenium Grid, one server acts as the hub that routes JSON formatted test commands to one or more registered Grid nodes. Tests contact the hub to obtain access to remote browser instances.| Selenium
Selenium HTML-runner allows you to run Test Suites from a command line. Test Suites are HTML exports from Selenium IDE or compatible tools. Common information Combination of releases of geckodriver / firefox / selenium-html-runner matters. There might be a software compatibility matrix somewhere. selenium-html-runner runs only Test Suite (not Test Case - for example an export from Monitis Transaction Monitor). Be sure you comply with this. For Linux users with no DISPLAY - you need to start h...| Selenium
First you need to install the Selenium bindings for your automation project. The installation process for libraries depends on the language you choose to use. Make sure you check the Selenium downloads page to make sure you are using the latest version. Requirements by language Java Python CSharp Ruby JavaScript Kotlin View the minimum supported Java version here. Installation of Selenium libraries for Java is accomplished using a build tool.| Selenium
There are only 5 basic commands that can be executed on an element: click (applies to any element) send keys (only applies to text fields and content editable elements) clear (only applies to text fields and content editable elements) submit (only applies to form elements) select (see Select List Elements) Additional validations These methods are designed to closely emulate a user’s experience, so, unlike the Actions API, it attempts to perform two things before attempting the specified act...| Selenium
Client Code Into the Driver We use the W3C WebDriver protocol to communicate with a local instance of an HTTP server. This greatly simplifies the implementation of the language-specific code, and minimzes the number of entry points into the C++ DLL that must be called using a native-code interop technology such as JNA, ctypes, pinvoke or DL. Memory Management The IE driver utilizes the Active Template Library (ATL) to take advantage of its implementation of smart pointers to COM objects.| Selenium
There are only 2 actions that can be accomplished with a keyboard: pressing down on a key, and releasing a pressed key. In addition to supporting ASCII characters, each keyboard key has a representation that can be pressed or released in designated sequences. Keys In addition to the keys represented by regular unicode, unicode values have been assigned to other keyboard keys for use with Selenium. Each language has its own way to reference these keys; the full list can be found here.| Selenium
These allow you to execute custom actions in every time specific Selenium commands are sent Java Python CSharp Ruby JavaScript Kotlin Add Example Add Example Add Example Add Example Add Example Add Example| Selenium
While Selenium 4 provides direct access to the Chrome DevTools Protocol, these methods will eventually be removed when WebDriver BiDi implemented. Console Logs Java Python CSharp Ruby JavaScript Kotlin ((HasLogEvents) driver).onLogEvent(consoleEvent(e -> messages.add(e.getMessages().get(0)))); View Complete Code View on GitHub /examples/java/src/test/java/dev/selenium/bidi/cdp/LoggingTest.java Copy Close package dev.selenium.bidi.cdp; import static org.openqa.selenium.devtools.events.CdpEvent...| Selenium
In Selenium 3, capabilities were defined in a session by using Desired Capabilities classes. As of Selenium 4, you must use the browser options classes. For remote driver sessions, a browser options instance is required as it determines which browser will be used. These options are described in the w3c specification for Capabilities. Each browser has custom options that may be defined in addition to the ones defined in the specification.| Selenium
Introduction Selenium RC was the main Selenium project for a long time, before the WebDriver/Selenium merge brought up Selenium 2, a more powerful tool. It is worth to highlight that Selenium 1 is not supported anymore. How Selenium RC Works First, we will describe how the components of Selenium RC operate and the role each plays in running your test scripts. RC Components Selenium RC components are: The Selenium Server which launches and kills browsers, interprets and runs the Selenese comma...| Selenium
Acceptance testing This type of testing is done to determine if a feature or system meets the customer expectations and requirements. This type of testing generally involves the customer’s cooperation or feedback, being a validation activity that answers the question: Are we building the right product? For web applications, the automation of this testing can be done directly with Selenium by simulating user expected behaviour. This simulation could be done by record/playback or through the ...| Selenium
How to Migrate to Selenium WebDriver A common question when adopting Selenium 2 is what’s the correct thing to do when adding new tests to an existing set of tests? Users who are new to the framework can begin by using the new WebDriver APIs for writing their tests. But what of users who already have suites of existing tests? This guide is designed to demonstrate how to migrate your existing tests to the new APIs, allowing all new tests to be written using the new features offered by WebDri...| Selenium
You will occasionally want to validate the colour of something as part of your tests; the problem is that colour definitions on the web are not constant. Would it not be nice if there was an easy way to compare a HEX representation of a colour with a RGB representation of a colour, or a RGBA representation of a colour with a HSLA representation of a colour? Worry not. There is a solution: the Color class!| Selenium
(Previously located: https://github.com/SeleniumHQ/selenium/wiki/Selenium-Emulation) Backing Selenium with WebDriver The Java and .NET versions of WebDriver provide implementations of the existing Selenium API. In Java, it is used like so: // You may use any WebDriver implementation. Firefox is used here as an example WebDriver driver = new FirefoxDriver(); // A "base url", used by selenium to resolve relative URLs String baseUrl = "http://www.google.com"; // Create the Selenium implementatio...| Selenium
Grid Grid Status Grid status provides the current state of the Grid. It consists of details about every registered Node. For every Node, the status includes information regarding Node availability, sessions, and slots. cURL GET 'http://localhost:4444/status' Delete session Deleting the session terminates the WebDriver session, quits the driver and removes it from the active sessions map. Any request using the removed session-id or reusing the driver instance will throw an error.| Selenium
These allow you to set various parameters for the HTTP library Java Python CSharp Ruby JavaScript Kotlin package dev.selenium.drivers; import dev.selenium.BaseTest; import org.openqa.selenium.remote.http.ClientConfig; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.RemoteWebDriver; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFa...| Selenium
For some browser configurations in Selenium RC, Selenium acted as a proxy between the browser and the site being automated. This meant that all browser traffic passed through Selenium could be captured or manipulated. The captureNetworkTraffic() method purported to capture all of the network traffic between the browser and the site being automated, including HTTP response codes. Selenium WebDriver is a completely different approach to browser automation, preferring to act more like a user.| Selenium
Note: this page has merged contents from multiple sources, including the Selenium wiki Overview Within your web app’s UI, there are areas where your tests interact with. A Page Object only models these as objects within the test code. This reduces the amount of duplicated code and means that if the UI changes, the fix needs only to be applied in one place. Page Object is a Design Pattern that has become popular in test automation for enhancing test maintenance and reducing code duplication.| Selenium
The Service classes are for managing the starting and stopping of local drivers. They cannot be used with a Remote WebDriver session. Service classes allow you to specify information about the driver, like location and which port to use. They also let you specify what arguments get passed to the command line. Most of the useful arguments are related to logging. Default Service instance To start a driver with a default service instance:| Selenium
All the options shown in CLI options can be configured through a TOML file. This page shows configuration examples for the different Grid components. Note that this documentation could be outdated if an option was modified or added but has not been documented yet. In case you bump into this situation, please check the “Config help” section and feel free to send us a pull request updating this page. Overview Selenium Grid uses TOML format for config files.| Selenium
This documentation previously located on the wiki You can read the documentation for the legacy Crazy Fun Build tool. Building Selenium with Buck The easiest thing to do is to just run “./go”. The build process will download the right version of Buck for you so long as there’s no .nobuckcheck file in the root of the project. The download ends up in buck-out/crazy-fun/HASH/buck.pex where HASH is the value of the current buck version (given in the .| Selenium
By default, Selenium 4 is compatible with Chrome v75 and greater. Note that the version of the Chrome browser and the version of chromedriver must match the major version. Options Capabilities common to all browsers are described on the Options page. Capabilities unique to Chrome and Chromium are documented at Google’s page for Capabilities & ChromeOptions Starting a Chrome session with basic defined options looks like this: Java Python CSharp Ruby JavaScript Kotlin ChromeOptions options = ...| Selenium
A cookie is a small piece of data that is sent from a website and stored in your computer. Cookies are mostly used to recognise the user and load the stored information. WebDriver API provides a way to interact with cookies with built-in methods: Add Cookie It is used to add a cookie to the current browsing context. Add Cookie only accepts a set of defined serializable JSON object. Here is the link to the list of accepted JSON key values| Selenium
How to customize a Node There are times when we would like a Node to be customized to our needs. For e.g., we may like to do some additional setup before a session begins execution and some clean-up after a session runs to completion. Following steps can be followed for this: Create a class that extends org.openqa.selenium.grid.node.Node Add a static method (this will be our factory method) to the newly created class whose signature looks like this:| Selenium
A domain specific language (DSL) is a system which provides the user with an expressive means of solving a problem. It allows a user to interact with the system on their terms – not just programmer-speak. Your users, in general, do not care how your site looks. They do not care about the decoration, animations, or graphics. They want to use your system to push their new employees through the process with minimal difficulty; they want to book travel to Alaska; they want to configure and buy ...| Selenium
Historically, this is the most common error beginning Selenium users get when trying to run code for the first time: Java Python CSharp Ruby The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://chromedriver.chromium.org/. The latest version can be downloaded from https://chromedriver.chromium.org/downloads The executable chromedriver needs to be available in the path. The file geckodriver does not exist. The driver can...| Selenium
This documentation previously located on the wiki \ Introduction WebDriver has a comprehensive suite of tests that describe the expected behavior of a new implementation. We’ll assume that you’re implementing the driver in Java for the sake of simplicity, but you can take a look at any of the existing implementations for how we handle more complex builds or other languages once you’ve read this. Writing a New WebDriver Implementation Create New Top-Level Directories Create a new top-lev...| Selenium
This documentation previously located on the wiki You can read more about geckodriver. About Firefox driver is included in the selenium-server-stanalone.jar available in the downloads. The driver comes in the form of an xpi (firefox extension) which is added to the firefox profile when you start a new instance of FirefoxDriver. Pros Runs in a real browser and supports Javascript Faster than the InternetExplorerDriver Cons Slower than the HtmlUnitDriver Important System Properties The followin...| Selenium
For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. Aside from being against the usage terms for these sites (where you risk having the account shut down), it is slow and unreliable. The ideal practice is to use the APIs that email providers offer, or in the case of Facebook the developer tools service which exposes an API for creating test accounts, friends and so forth.| Selenium
To use Selenium Grid, you need to maintain your own infrastructure for the nodes. As this can be a cumbersome and time intense effort, many organizations use IaaS providers such as Amazon EC2 and Google Compute to provide this infrastructure. Other options include using providers such as Sauce Labs or Testing Bot who provide a Selenium Grid as a service in the cloud. It is certainly possible to also run nodes on your own hardware.| Selenium
There are a number of details you can query about a specific element. Is Displayed This method is used to check if the connected Element is displayed on a webpage. Returns a Boolean value, True if the connected element is displayed in the current browsing context else returns false. This functionality is mentioned in, but not defined by the w3c specification due to the impossibility of covering all potential conditions. As such, Selenium cannot expect drivers to implement this functionality d...| Selenium
Turning on logging is a valuable way to get extra information that might help you determine why you might be having a problem. Getting a logger Java Python CSharp Ruby JavaScript Kotlin Java logs are typically created per class. You can work with the default logger to work with all loggers. To filter out specific classes, see Filtering Get the root logger: Logger logger = Logger.getLogger(""); View Complete Code View on GitHub /examples/java/src/test/java/dev/selenium/troubleshooting/LoggingT...| Selenium
There are only 3 actions that can be accomplished with a mouse: pressing down on a button, releasing a pressed button, and moving the mouse. Selenium provides convenience methods that combine these actions in the most common ways. Click and hold This method combines moving the mouse to the center of an element with pressing the left mouse button. This is useful for focusing a specific element: Java Python CSharp Ruby JavaScript Kotlin WebElement clickable = driver.| Selenium
While Selenium 4 provides direct access to the Chrome DevTools Protocol, these methods will eventually be removed when WebDriver BiDi implemented. Basic authentication Some applications make use of browser authentication to secure pages. It used to be common to handle them in the URL, but browsers stopped supporting this. With this code you can insert the credentials into the header when necessary Java Python CSharp Ruby JavaScript Kotlin Predicate<URI> uriPredicate = uri -> uri.| Selenium
This documentation previously located on the wiki 2.9.1 - to be released Fix - Fixes https://github.com/SeleniumHQ/selenium/issues/396 Fix - Changed Google code links to GitHub. Enh - Merged official language plugins into the main xpi eliminating the need for multi-xpi with the main xpi and multiple language plugin xpis. Fix - Fixes https://github.com/SeleniumHQ/selenium/issues/570 2.9.0 Enh - Schedule tests for automatic playback at a certain time or periodic intervals. (http://blog.reallysi...| Selenium
When would you use a Selenium Grid? To run your tests in parallel, against different browser types, browser versions, operating systems To reduce the time needed to execute a test suite Selenium Grid runs test suites in parallel against multiple machines (called Nodes). For large and long-running test suites, this can save minutes, hours, or perhaps days. This shortens the turnaround time for test results as your application under test (AUT) changes.| Selenium
Microsoft Edge is implemented with Chromium, with the earliest supported version of v79. Similar to Chrome, the major version number of edgedriver must match the major version of the Edge browser. Options Capabilities common to all browsers are described on the Options page. Capabilities unique to Chromium are documented at Google’s page for Capabilities & ChromeOptions Starting an Edge session with basic defined options looks like this: Java Python CSharp Ruby JavaScript Kotlin EdgeOptions...| Selenium
Table of Contents Introduction Setup Database backed Session Map Steps Redis backed Session Map Steps Introduction Selenium Grid allows you to persist information related to currently running sessions into an external data store. The external data store could be backed by your favourite database (or) Redis Cache system. Setup Coursier - As a dependency resolver, so that we can download maven artifacts on the fly and make them available in our classpath Docker - To manage our PostGreSQL/Redis ...| Selenium
Selenium should not be used to prepare a test case. All repetitive actions and preparations for a test case, should be done through other methods. For example, most web UIs have authentication (e.g. a login form). Eliminating logging in via web browser before every test will improve both the speed and stability of the test. A method should be created to gain access to the AUT* (e.g. using an API to login and set a cookie).| Selenium
Chromium Only A Pen is a type of pointer input that has most of the same behavior as a mouse, but can also have event properties unique to a stylus. Additionally, while a mouse has 5 buttons, a pen has 3 equivalent button states: 0 — Touch Contact (the default; equivalent to a left click) 2 — Barrel Button (equivalent to a right click) 5 — Eraser Button (currently unsupported by drivers) Using a Pen Java Python CSharp Ruby JavaScript Kotlin Selenium v4.| Selenium
The Select object will now give you a series of commands that allow you to interact with a <select> element. If you are using Java or .NET make sure that you’ve properly required the support package in your code. See the full code from GitHub in any of the examples below. Note that this class only works for HTML elements select and option. It is possible to design drop-downs with JavaScript overlays using div or li, and this class will not work for those.| Selenium
A common idea and misconception about automated testing is regarding a specific test order. Your tests should be able to run in any order, and not rely on other tests to complete in order to be successful.| Selenium
This documentation previously located on the wiki General architecture We have a number of Google Compute Engine virtual machines running Ubuntu, currently hosted at {0..29}.ci.seleniumhq.org - they have publicly addressable DNS set up to point ab.{0..29}.ci.seleniumhq.org pointing at them as well, so that cookie tests can do subdomain lookups. One of these machines, ci.seleniumhq.org, is running jenkins. If you want a login on jenkins, get in touch with juangj. The Build All Java job polls S...| Selenium
Selenium Grid 4 is a ground-up rewrite from previous versions. In addition to a comprehensive set of improvements to performance and standards compliance, the different functions of the grid were broken out to reflect a more modern age of computing and software development. Purpose-build for containerization and cloud-distributed scalability, Selenium Grid 4 is a wholly new solution for the modern era. Router The Router is the entry point of the Grid, receiving all external requests, and forw...| Selenium
Selenium 4 requires Firefox 78 or greater. It is recommended to always use the latest version of geckodriver. Options Capabilities common to all browsers are described on the Options page. Capabilities unique to Firefox can be found at Mozilla’s page for firefoxOptions Starting a Firefox session with basic defined options looks like this: Java Python CSharp Ruby JavaScript Kotlin FirefoxOptions options = new FirefoxOptions(); driver = new FirefoxDriver(options); View Complete Code View on G...| Selenium
Frames are a now deprecated means of building a site layout from multiple documents on the same domain. You are unlikely to work with them unless you are working with an pre HTML5 webapp. Iframes allow the insertion of a document from an entirely different domain, and are still commonly used. If you need to work with frames or iframes, WebDriver allows you to work with them in the same way.| Selenium
Hub Intermediary and manager Accepts requests to run tests Takes instructions from client and executes them remotely on the nodes Manages threads A Hub is a central point where all your tests are sent. Each Selenium Grid consists of exactly one hub. The hub needs to be reachable from the respective clients (i.e. CI server, Developer machine etc.) The hub will connect one or more nodes that tests will be delegated to.| Selenium
Eliminating the dependencies on external services will greatly improve the speed and stability of your tests.| Selenium
Performance testing using Selenium and WebDriver is generally not advised. Not because it is incapable, but because it is not optimised for the job and you are unlikely to get good results. It may seem ideal to performance test in the context of the user but a suite of WebDriver tests are subjected to many points of external and internal fragility which are beyond your control; for example browser startup speed, speed of HTTP servers, response of third party servers that host JavaScript or CS...| Selenium
While Selenium 4 provides direct access to the Chrome DevTools Protocol, these methods will eventually be removed when WebDriver BiDi implemented. Script Pinning Java Python CSharp Ruby JavaScript Kotlin ScriptKey key = ((JavascriptExecutor) driver).pin("return arguments;"); List<Object> arguments = (List<Object>) ((JavascriptExecutor) driver).executeScript(key, 1, true, element); View Complete Code View on GitHub /examples/java/src/test/java/dev/selenium/bidi/cdp/ScriptTest.java Copy Close p...| Selenium
Read our contributing documentation for complete instructions on how to add content to this documentation. Alerts Alerts have been added to direct potential contributors to where specific content is missing. {{< alert-content />}} or {{< alert-content >}} Additional information about what specific content is needed {{< /alert-content >}} Which gets displayed like this: Content Help Note: This section needs additional and/or updated content Additional information about what specific content is...| Selenium
This class is only available in the Java Binding ThreadGuard checks that a driver is called only from the same thread that created it. Threading issues especially when running tests in Parallel may have mysterious and hard to diagnose errors. Using this wrapper prevents this category of errors and will raise an exception when it happens. The following example simulate a clash of threads: public class DriverClash { //thread main (id 1) created this driver private WebDriver protectedDriver = Th...| Selenium
Perhaps the most common challenge for browser automation is ensuring that the web application is in a state to execute a particular Selenium command as desired. The processes often end up in a race condition where sometimes the browser gets into the right state first (things work as intended) and sometimes the Selenium code executes first (things do not work as intended). This is one of the primary causes of flaky tests.| Selenium
Selenium v4.2 Chromium Only There are 5 scenarios for scrolling on a page. Scroll to element This is the most common scenario. Unlike traditional click and send keys methods, the actions class does not automatically scroll the target element into view, so this method will need to be used if elements are not already inside the viewport. This method takes a web element as the sole argument. Regardless of whether the element is above or below the current viewscreen, the viewport will be scrolled...| Selenium
Selenium is not designed to report on the status of test cases run. Taking advantage of the built-in reporting capabilities of unit test frameworks is a good start. Most unit test frameworks have reports that can generate xUnit or HTML formatted reports. xUnit reports are popular for importing results to a Continuous Integration (CI) server like Jenkins, Travis, Bamboo, etc. Here are some links for more information regarding report outputs for several languages.| Selenium
Using WebDriver to spider through links is not a recommended practice. Not because it cannot be done, but because WebDriver is definitely not the most ideal tool for this. WebDriver needs time to start up, and can take several seconds, up to a minute depending on how your test is written, just to get to the page and traverse through the DOM. Instead of using WebDriver for this, you could save a ton of time by executing a curl command, or using a library such as BeautifulSoup since these metho...| Selenium
Printing a webpage is a common task, whether for sharing information or maintaining archives. Selenium simplifies this process through its PrintOptions, PrintsPage, and browsingContext classes, which provide a flexible and intuitive interface for automating the printing of web pages. These classes enable you to configure printing preferences, such as page layout, margins, and scaling, ensuring that the output meets your specific requirements. Configuring Orientation Using the getOrientation()...| Selenium
Although mentioned in several places, it is worth mentioning again. We must ensure that the tests are isolated from one another. Do not share test data. Imagine several tests that each query the database for valid orders before picking one to perform an action on. Should two tests pick up the same order you are likely to get unexpected behavior. Clean up stale data in the application that might be picked up by another test e.| Selenium
Once you have Selenium installed, you’re ready to write Selenium code. Eight Basic Components Everything Selenium does is send the browser commands to do something or send requests for information. Most of what you’ll do with Selenium is a combination of these basic commands Click on the link to “View full example on GitHub” to see the code in context. 1. Start the session For more details on starting a session read our documentation on driver sessions| Selenium
This documentation previously located on the wiki You can read our documentation for more information about Grid 4 Introduction Grid allows you to : scale by distributing tests on several machines ( parallel execution ) manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS. minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance.| Selenium
As of June 2022, Selenium officially no longer supports standalone Internet Explorer. The Internet Explorer driver still supports running Microsoft Edge in “IE Compatibility Mode.” Special considerations The IE Driver is the only driver maintained by the Selenium Project directly. While binaries for both the 32-bit and 64-bit versions of Internet Explorer are available, there are some known limitations with the 64-bit driver. As such it is recommended to use the 32-bit driver.| Selenium
Take a look at examples of the supported locator strategies. In general, if HTML IDs are available, unique, and consistently predictable, they are the preferred method for locating an element on a page. They tend to work very quickly, and forego much processing that comes with complicated DOM traversals. If unique IDs are unavailable, a well-written CSS selector is the preferred method of locating an element. XPath works as well as CSS selectors, but the syntax is complicated and frequently d...| Selenium
This documentation previously located on the wiki What is Google Summer of Code? Since 2005, Google has administered Google Summer of Code Program to encourage student participation in open source development. The program has several goals: Inspire young developers to begin participating in open source development Provide students in Computer Science and related fields the opportunity to do work related to their academic pursuits during the summer Give students more exposure to real-world sof...| Selenium
Two Factor Authentication (2FA) is an authorization mechanism where a One Time Password (OTP) is generated using “Authenticator” mobile apps such as “Google Authenticator”, “Microsoft Authenticator” etc., or by SMS, e-mail to authenticate. Automating this seamlessly and consistently is a big challenge in Selenium. There are some ways to automate this process. But that will be another layer on top of our Selenium tests and not as secure. So, you should avoid automating 2FA.| Selenium
Windows and tabs Get window handle WebDriver does not make the distinction between windows and tabs. If your site opens a new tab or window, Selenium will let you work with it using a window handle. Each window has a unique identifier which remains persistent in a single session. You can get the window handle of the current window by using: Move Code Java Python CSharp Ruby JavaScript Kotlin // Navigate to Url driver.| Selenium
Write each test as its own unit. Write the tests in a way that will not be reliant on other tests to complete: Let us say there is a content management system with which you can create some custom content which then appears on your website as a module after publishing, and it may take some time to sync between the CMS and the application. A wrong way of testing your module is that the content is created and published in one test, and then checking the module in another test.| Selenium
The Grid is designed as a set of components that all fulfill a role in maintaining the Grid. It can seem quite complicated, but hopefully this document can help clear up any confusion. The Key Components The main components of the Grid are: Event Bus Used for sending messages which may be received asynchronously between the other components. New Session Queue Maintains a list of incoming sessions which have yet to be assigned to a Node by the Distributor.| Selenium
Martin Fowler coined the term “Fluent API”. Selenium already implements something like this in their FluentWait class, which is meant as an alternative to the standard Wait class. You could enable the Fluent API design pattern in your page object and then query the Google search page with a code snippet like this one: driver.get( "http://www.google.com/webhp?hl=en&tab=ww" ); GoogleSearchPage gsp = new GoogleSearchPage(driver); gsp.setSearchString().clickSearchButton(); The Google page...| Selenium
This documentation previously located on the wiki You can read more about Grid 2 Selenium Grid Platforms This section describes the PLATFORM option used in configuring Selenium Grid Nodes and [DesiredCapabilities] object. History of Platforms When requesting a new WebDriver session from the Grid, user can specify the [DesiredCapabilities] of the remote browser. Things such as the browser name, version, and platform are among the list of options that can be specified by the test.| Selenium
Selenium’s Integrated Development Environment (Selenium IDE) is an easy-to-use browser extension that records a user’s actions in the browser using existing Selenium commands, with parameters defined by the context of each element. It provides an excellent way to learn Selenium syntax. It’s available for Google Chrome, Mozilla Firefox, and Microsoft Edge. For more information, visit the complete Selenium IDE Documentation| Selenium
The endpoints and payloads for the now-obsolete open source protocol that was the precursor to the [W3C specification](https://w3c.github.io/webdriver/).| Selenium
| Tags on Selenium
| Tags on Selenium