Select Page

Category Selected: 2016

53 results Found

People also read

API Testing

Postman API Automation Testing Tutorial

Automation Testing

Top 10 AI Automation Testing Tools

Automation Testing

Talk to our Experts

Amazing clients who
trust us


New Methods in WebDriver ExpectedConditions Class

In Selenium WebDriver 2.53.0 release, we have new methods addition in ExpectedConditions class. All are really helpful for extensive validations and adding synchronization points in test scripts.

Attribute Validation


Waiting for Elements Count


Waiting for a text in an element


White Framework Wait Commands

The White framework does not send an action until a window has entered the idle state after the previous action. In that case, White framework waits automatically if a window is busy.

But how to wait for an element or a particular condition? How to avoid Thread.sleep during automation script development? In White, we can write our synchronization points. In this article, we will show you White framework waiting techniques and commands which are being used in all our desktop automation testing projects at Codoid.

Wait Based On HourGlass

Using WaitBasedOnHourGlass property (default value true), you can configure wait based on presence of hour glass.

CoreAppXmlConfiguration.Instance.WaitBasedOnHourGlass = true;
WaitTill Method

WaitTill is one of the methods for Window object. You can use this method to wait until the certain condition matches.

Label lbl = window.Get

In the above example, the script waits until the label field visibility=true. The default wait time is 5000 milliseconds.

You can also change the Default wait time by setting BusyTimeout property as shown below.

CoreAppXmlConfiguration.Instance.BusyTimeout = 10000;
WaitWhileBusy method
Window window = application.GetWindow("Calculator");

WaitWhileBusy method makes your script wait until the window is busy. Note: You no need to call this method for every action as it is called automatically at the end of every action.

Wait Hook

If you want to write your custom delay and the written custom code needs to be called after every action, then you can use IWaitHook interface as shown below.

public class CustomWait : IWaitHook
public CustomWait()
CoreAppXmlConfiguration.Instance.AdditionalWaitHook = this;

// Implementation of the IWaitHook interface
public void WaitFor(UIItemContainer uiItemContainer)

WebDriver Mouse Hover

WebDriver Mouse Hover

This is our very first article in Selenium, we hope it is helpful for Selenium users. Keep visiting Codoid blogs for more articles in the near future.

Using Custom JavaScript Mouse-event

//The below JavaScript code creates, initializes and dispatches mouse event to an object on fly.
String strJavaScript = "var element = arguments[0];"
            + "var mouseEventObj = document.createEvent('MouseEvents');"
            + "mouseEventObj.initEvent( 'mouseover', true, true );"
            + "element.dispatchEvent(mouseEventObj);";
//Then JavascriptExecutor class is used to execute the script to trigger the dispatched event.
((JavascriptExecutor) driver).executeScript(strJavaScript, element);


Using Device

//Getting mouse from driver object
Mouse mouse =((HasInputDevices)driver).getMouse();
//Invokes mouseMove method by passing element coordinates as argument


Using Advanced User Interactions API

Actions builder = new Actions(driver);

//Note:  (Preferable for Firefox and HTMLUnit drivers)

Resizing and Positioning Window

Browser window resizing and positioning can be done easily using Selenium WebDriver. Consider we have opened multiple browser windows in same machine for parallel execution; it is very useful to view execution on each window, if it is positioned and re-sized for user view at run-time.

Window Resize

driver.manage().window().setSize(new Dimension(100,100));

//Note: Dimension should be imported using org.openqa.selenium.Dimension


Window Position

driver.manage().window().setPosition(new Point(100,100));

//Note: Point should be imported using org.openqa.selenium.Point

Stopping Selenium Server Using HTTP Client

In this blog article, we show you how to stop Selenium Server using Apache HTTP Client GET method. The Apache HttpClient library simplifies handling HTTP requests. To use this library download the binaries with dependencies from

//URL to stop Selenium Server
String strURL="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer";

//HTTP Default client Object
HttpClient client = new DefaultHttpClient();

//HTTP Get Object
HttpGet request = new HttpGet(strURL);

//Executing the request
HttpResponse response = client.execute(request);

Read more about Apache HTTP Client

CSS nth-child Selector

CSS nth-child Selector

In CSS Selector, we have a very useful structural pseudo-class selector i.e. ‘nth-child’ selector. ‘nth-child’ can be used to select ordered elements by giving the expression (an+b) or single element with positive integer as an argument. Consider if you want to get odd rows from a HTML table using Selenium WebDriver, your immediate idea will be ‘separating odd rows using FOR loop’. But we can accomplish it using nth-child (2n+1) selector.

nth-child (2n+1) expanded below.
(2*0) + 1=1=1st Row
(2*1) + 1=3=3rd Row
(2*2) + 1=5=5th Row

Selenium WebDriver-Java code below counts no. of odd rows in a table.

int inCount=driver.findElements(By.cssSelector("table[id='tbl1'] tr:nth-child(2n+1)")).size();

The below code gets first row from a table.

WebElement firstRow=driver.findElement(By.cssSelector("table[id='tbl1'] tr:nth-child(1)"));

Browser Compatibility

IE9+, FF 11.0+ on Win, FF 10.0.2+ on Mac, Safari 5.1, Chrome 18+ on Win and Chrome 17+ Mac.