Monday, July 22, 2013

Callable vs Runnable in java. Callable usage example.

Callable interface appeared in java.util.concurrent package in Java 1.5. Like a Runnable interface, Callable has the same purpose – to create executable tasks. But it provides more possibilities:

Thursday, July 18, 2013

Drag and Drop element using selenium example

In this article we will see how to drag and drop element using selenium. As example let's take JQuery slider to drag it's handle.
I will use JQuery slider from http://ui-dev.jquery.com/demos/slider/ page.

Sunday, July 7, 2013

Concurrency in java. ExecutorService.

High-level API for concurrency support appeared in Java 5. It includes different tools that make easier life for developers who work with a multi-threaded environment.

In particular, java.util.concurrent package contains a number of classes that help quick organize a thread pool. The following class diagram illustrates their hierarchy:

Check broken links on a Page using Selenium

In order to find and check broken links on a Page using Selenium we can do next steps:
1. Find all links using findElements() method.

2. Check each link response using java.net.HttpURLConnection class. (if page return 404 code - link is broken)

All these steps realized and described below:

Saturday, July 6, 2013

ScheduledThreadPoolExecutor in examples.

ScheduledThreadPoolExecutor extends capabilities of ThreadPoolExecutor (class diagram here) and makes it possible to schedule tasks execution.


ScheduledExecutorService interface gives new methods:

- two of them for scheduling action (Runnable or Callable) to execute just ones:

schedule (Callable<V> callable, long delay, TimeUnit unit): <V> ScheduledFuture<V>


schedule (Runnable command, long delay, TimeUnit unit): ScheduledFuture<?>


- and two others for periodic task execution:

scheduleAtFixedRate (Runnable command, long initialDelay, long period, TimeUnit unit): ScheduledFuture<?>


scheduleWithFixedDelay (Runnable command, long initialDelay, long delay, TimeUnit unit): ScheduledFuture<?>


Let’s see how they work.

Wednesday, July 3, 2013

How to add FireBug extension in FireFox profile.

No need to explain how convinient and useful to have FireBug extension in a browser if you work with tools like Selenium WebDriver. Firebug is a powerfull extension that allows us inspect elements and their properties, find element's Xpath.
Let’s see how to add firebug extension in FireFoxProfile for debugging selenium tests in runtime.

Saturday, June 29, 2013

Creating firefox profile for selenium tests

Sometimes it’s really useful to start Firefox browser with preconfigured properties in it's profile
It allows us to add some firefox addons like FireBug, and also using “setPreference()” method we can customize Firefox settings for out tests.


Let's look into a simple firefox profile for selenium tests example:

Friday, June 28, 2013

ThreadPoolExecutor example

Let’s create a pool with fixed number of threads and execute tasks using it.

Assume that we have some list of elements and each of them should be processed by the same way. But processing takes a lot of time and we decided to use pool of threads.

Wednesday, June 26, 2013

How to take screenshot using Selenium WebDriver

There are several ways how to take screenshot using Selenium or some Java solutions.The easiest way is to use already defined in WebDriver method getScreenshotAs()