how to create a sample selenium program

creating a sample selenium program is very simple you need to create a new project and add a class to new project and save. Now add the selenium library to your IDE Build path.

For example I am creating a sample programs for navigating to a webpage .

For Navigating to Web Page we need a method called "get" which lies inside a class WebDriver , This class is provided by the Selenium library .

We wont talk about TestNG because we don't need it now.

The test step would be

1. You need to fireup the web browser
2. navigate to webpage.

so the code will be like this.

package seleniumsampleproject;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
 * @author pradeek 
public class SeleniumSampleProject {
    public static WebDriver driver;
    public static void main(String[] args) {
        driver = new FirefoxDriver();

Here we created a instance of WebDriver class as driver and copying the firefox object to driver instance then navigate using get method.

No comments:

Post a Comment


selenium javascript alert box

This is a easy task to capture javascript based alertbox , /* * To change this license header, choose License Headers in Project Properti...