Selenium Knowledgebase

  • Handling Iframes In Selenium (Java)

    Often Website will use Iframes to contain some elements in a way which makes finding said elements difficult in a Selenium test. To switch the drivers focus to an Iframe you need to use driver.switchTo().frame(identifier) where the identifier is either the index, name or ID of the iframe.

    To show this in an example here is a code snippet:

  • Is Selenium WebDriver an Interface?

    Selenium WebDriver is an interface.

    For those unfamiliar with the term, an interface is a class which cannot be instantiated but can be implemented by classes that can.

    Selenium WebDriver is implemented by ChromeDriver for example, meaning that you can create an instance of ChromeDriver and interact with it as you would with any other object, however your code will not be compilable when trying to implement a pure WebDriver object.

  • Selenium 2 vs Selenium 3

    Selenium 2 is a combination of Selenium WebDriver and Selenium RC (Selenium 1) which is based on Selenium-Core. Selenium-Core is a JS program encompassing a set of JS actions which interpret and execute Selenium commands. With Selenium 3, the core is replaced with the back-end WebDriver, with Selenium RC indirectly accessible from this WebDriver.

    Other differences between the two include:

  • Page Object Model Basics

    One the more popular design patterns for Selenium is the Page Object Model. The general idea of page object model is to programmatically model each page for the tested website in classes separate to your test cases. Each class will implement logic specific to that page. In your test cases you will mainly be entering commands written in these Page classes.

  • How Selenium Interacts With The Browser

    Among other technologies, Selenium contains a WebDriver it uses to communicate with a browser. This WebDriver acts as a middle man between a programming language and the window. By entering commands in your chosen language, the WebDriver will interpret and enter them into the browser as if a user did it. Through the same mechanism the

  • Getting org.openqa.selenium.TimeoutException: No connection could be made because the target machine actively refused it.

    This particular error message means that your computer could connect to the target server but the server refused the connection. A common cause of this error is that you connected to the wrong port when creating a connection. If you know that the port is correct then it is also possible that the server's firewall blocked your machine from connecting.

  • Stale Element Reference Exception Selenium (java)

    StaleElementReferenceException is an exception which tells us that the WebElement that the test is trying to interact with is no longer present in the document. This can happen for a number of reasons but most of the time it is because you have either navigated away from a page with the element contained within or you have closed the dialog that is its parent.

    The following example shows two portions of test code:

  • Selenium Webdriver action chains (Java)

    With Selenium Webdriver it is possible to create a chain of actions to implemented with one line of code. This is done with the Actions class. Actions is implemented with an instance of the WebDriver and can be used for such actions like click and drag or moving the mouse to hover over an element before interacting with it. Below is a script showing an example of action chains:

  • Is selenium a framework or a tool?

    Generally, In automation a tool is considered to be an instrument to carry out specific functions in software design. A framework however is a collection of various tools and procedures used for more complicated projects. Selenium is considered to be a framework because it encompasses a variety of tools to aid the end goal of automating user interfaces.

  • Locators In Selenium WebDriver (Java/Python)

    In selenium, you can only locate elements using locators, commands which when provided the correct input, will tell the webdriver which element on the page to look for. The locators can be chosen based on which search condition you want to use, for certain commonly used tags there will be locators available specifically for them such as ID, link text or name, etc. Each language has its own way of using locators, For example:

Pages