From today I am going to give basic concept on automated functional testing using Geb and Selenium.Today I am going to explain Selenium concept and in next session I will explain Geb and how to use Selenium in Geb. First-of-all be clear that Selenium and Geb are used for automated functional testing.
To use Selenium just put the plug-in in BuildConfig.groovy:


dependencies {

compile org.seleniumhq.selenium:selenium-chrome-driver:2.3.0;
compile org.seleniumhq.selenium:selenium-firefox-driver:2.39.0;

}

Now just make a functional testing class as defined below:


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;

public class SampleTestSpec{

public static void main(String[] args)
{
WebDriver d1 = new FirefoxDriver();
//defined the webdriver 
d1.get("http://www.google.com");
// fetched the URL
try {
Thread.sleep(1000);
//told browser to sleep for 1000 millisecond
} catch (InterruptedException e) {
e.printStackTrace();
};
d1.findElement(By.className("gbqfif")).sendKeys("facebook");
//setting text in text-field of Google
d1.findElement(By.id("gbqfba")).click();
//clicking on search button
}

}

Here I have used java code you could use any programing language which are supported by Selenium and Geb.

Screenshot from 2014-01-20 13:35:56Click to Enlarged

Here is the resultant screen when we run the SampleTestSpec.In next session I will explain you how to use Selenium via Geb.