Select Page

Category Selected: Selenium Testing

47 results Found


People also read

E-Learning Testing

What is LMS Testing? Explore Effective Strategies

Software Development

Building RESTful APIs with Node.js and Express

Security Testing

Talk to our Experts

Amazing clients who
trust us


poloatto
ABB
polaris
ooredo
stryker
mobility
Third Party Selenium Client Bindings

Third Party Selenium Client Bindings

We know that there are multiple Selenium Client bindings available to automate web applicationsusing different programming languages and the client binding list is already available in SeleniumHQ website. In this blog article, we have listed the third party Selenium client bindings which are not known to many.

CrystalSelenium Webdriver bindings for the Crystal programming language.

GoThe most complete, best-tested WebDriver client for Go

C++A C++ client library for Selenium Webdriver. BEWARE! This code has never been in production, uses very old dialect of C++ and is not maintained. It could be, theoretically, used as a starting point for a new development, but definitely not as a production-ready library.

RustA Rust Client for the Selenium webdriver (WIP)

JuliaThis is a wrapper around Selenium WebDriver’s python bindings. It can be used to write web-browser interaction tests in Julia.

Common LispAsh is a Selenium client for Common Lisp. It was written against the Selenium 2.x JSON wire protocol.

Selenium 4.0 Command to Open New Window & Tab

Selenium 4.0 Command to Open New Window & Tab

In Selenium 4.0, you can open new window & tab using “newWindow” command. Please note: Selenium 4.0 is yet to be released. However, you can try this feature using Firefox 66 & Selenium 4.0.0-alpha-1 versions.

Selenium 4.0 (Alpha) Maven Dependency

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-1</version>
</dependency>

Code

System.setProperty("webdriver.gecko.driver", "drivers/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.switchTo().newWindow(WindowType.WINDOW);
driver.switchTo().newWindow(WindowType.TAB);

Follow our blog to receive Selenium related updates.

Selenium 4 – Chrome DevTools Log Entry Listeners

Selenium 4 – Chrome DevTools Log Entry Listeners

Sometimes, logs from Chrome are useful to understand application’s issues. However, when the Selenium is being executed, we can’t capture and verify Chrome logs.

In Selenium 4, you can listen Chrome Console logs using “Devtools” interface. In this blog, you will learn how to listen Chrome console logs using Selenium 4.0 (Alpha).

Selenium 4.0 (Alpha) Maven Dependency

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-alpha-1</version>
</dependency>
  

Sample Code

DevTools devTools = ((ChromeDriver)driver).getDevTools();

devTools.createSession();
devTools.send(Log.enable());

devTools.addListener(Log.entryAdded(), entry -> System.out.println(entry.asSeleniumLogEntry()));
  

Using the above code, Chrome DevTools Console logs can be published in Log4j or LogBack files.

Full Code

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.Log;
import org.slf4j.*;

public class Selenium4Devtools {
    final static Logger logger = LoggerFactory.getLogger(Selenium4Devtools.class);

    public static void main(String args[]){

        System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();

        try{

            DevTools devTools = ((ChromeDriver)driver).getDevTools();

            devTools.createSession();
            devTools.send(Log.enable());

            devTools.addListener(Log.entryAdded(), entry -> logger.error(entry.asSeleniumLogEntry().getMessage()));

            driver.get("http://www.codoid.com");

        }
        catch(Exception e){
            e.printStackTrace();
        }
        finally {
            driver.quit();
        }
    }
}
Exploring IE Driver Desired Capabilities

Exploring IE Driver Desired Capabilities

The experts who are using Selenium WebDriver from the beginning, they are aware of how IE Driver was evolved and what are all the desired capabilities were introduced. However, many don’t know the IE driver settings and options which are required and why do we need them while instantiating WebDriver. As a leading software testing company, creating robust automated test scripts is one of the core values. Today, we will share important IE driver configurations which every automation tester should be familiar with.

Disable Native Events

By default, the IE driver uses native events i.e. Using Windows OS Level messaging to simulate user keyboard and mouse inputs. If you want all your Selenium actions to be performed through JavaScript or you are facing slowness in entering values in textboxes, then disable native events as shown below.

InternetExplorerOptions options = new InternetExplorerOptions();

options.disableNativeEvents();

WebDriver driver = new InternetExplorerDriver(options);
  

Enable Persistent Hovering

IE driver window receives WM_MOUSEMOVE message to perform native mouseover event. However, we have a problem with this. The hover native event will be very quick and it won’t persist. Hovering should happen as same as how an user does. If you enable Persistent Hovering, the WM_MOUSEMOVE message will be sent to the IE window multiple times to hover on a webelement in a separate thread.

InternetExplorerOptions options = new InternetExplorerOptions();

options.enablePersistentHovering();
  

Introduce Flakiness By Ignoring Security Domains

Never use this setting unless if your windows machine does not have the registry access to check the protected mode settings via WebDriver code. Whenever IE driver is instantiated, it will check Protected Mode settings in Windows Registry. If you want to ignore this checking, you can use this setting to ignore Protected Mode settings verification.

Note: Don’t use “introduceFlakinessByIgnoringSecurityDomains” setting even though the protected mode settings are configured correctly and you have necessary access for the registry settings.

InternetExplorerOptions options = new InternetExplorerOptions();

options.introduceFlakinessByIgnoringSecurityDomains();
  

Ignore Zoom Settings

Whenever IE driver is launched, WebDriver will check whether the IE Zoom Level Setting is set to (100%). Setting 100% will ensure the automated testing execution robust and your Selenium WebDriver commands won’t fail due to page formatting and WebElement sizing issues. If you want to ignore this detection while launching the IE driver, you can use “ignoreZoomSettings”.

InternetExplorerOptions options = new InternetExplorerOptions();
options.ignoreZoomSettings();
  
How to set Network Conditions in Selenium?

How to set Network Conditions in Selenium?

If you want to run your Selenium script in different network conditions, you can do it using Chrome CommandExecutor.

Using Chrome Developer Tools, you can emulate different network conditions to check your app’s performance. If you want this to be implemented in automation testing, we have a command to do that. Let’s see with an example.

System.setProperty("webdriver.chrome.driver","drivers/chromedriver.exe");

ChromeDriver driver = new ChromeDriver();
        
CommandExecutor executor = driver.getCommandExecutor();
        
//Set the conditions
Map<String, Object> map = new HashMap<String, Object>();
map.put("offline", false);
map.put("latency", 5);
map.put("download_throughput", 5000);
map.put("upload_throughput", 5000);

Response response = executor.execute(new Command(driver.getSessionId(),"setNetworkConditions", ImmutableMap.of("network_conditions", ImmutableMap.copyOf(map))));

driver.get("http://google.com");
  

Initially, we didn’t have this implementation in Java bindings to set network conditions. After a fix from Andrii Rohovets, GET_NETWORK_CONDITIONS, SET_NETWORK_CONDITIONS and DELETE_NETWORK_CONDITIONS are available to emulate network conditions in Selenium & Java.

Latest Selenium Commands

Latest Selenium Commands

This blog article explains the latest Selenium Commands and methods which every automation tester must know. As an automation testing company, we keenly watch the enhancements in Selenium WebDriver to improve our test automation scripting for a robust solution. Let’s see the new Selenium commands one by one.

Latest Selenium Commands

WrapsElement

You can’t get the wrapped webelement from Select object once it is wrapped using Select class for Dropdown and List actions. However, in Selenium v3.141.59, you can get the wrapped element using getWrappedElement() method. Please see the below example.

Select select = new Select(dropDown);

select.getWrappedElement();  
  

Before and After GetText Methods

WebDriverEventListener class is used to view the events triggered by webdriver. Selenium version 3.13.0 has introduced two new methods (beforeGetText & afterGetText) in WebDriverEventListener class.

public class CustomListener implements WebDriverEventListener {

    public void beforeGetText(WebElement element, WebDriver driver) {

    }

    public void afterGetText(WebElement element, WebDriver driver, String text) {

    }
}
  

The above methods will be invoked before and after calling getText method for a webElement.

WebStorage

Web storage a provides a way for your web applications to store data locally within the user’s browser. There are two types of Webstorage (Local & Session). Local storage stores data with no expiration date. Session storage is similar to local storage, except that it stores data for one session only. You can get the local and session storage using the below snippet.

WebDriver driver = new ChromeDriver(chromeOptions);

((ChromeDriver) driver).getSessionStorage().size();
  

OkHttp

Now Selenium Grid communication between Hubs and Nodes is using OkHttp instead of the Apache HttpClient. OkHTTP is an open source project designed to be an efficient HTTP client. It supports the SPDY protocol. SPDY is the basis for HTTP 2.0 and allows multiple HTTP requests to be multiplexed over one socket connection.