Here is a simple example that explains how to write a test using selenium rc(selenium 1).
Note: Make sure that you have started the selenium server before running the test.
Follow the following steps to write your 1st test using selenium rc.
- Open your desired Java IDE (in my case Eclipse)
- Create a java project.
- Create a package 'test.example' and add a new class 'GoogleTest.java' to it.
- Create a folder namely 'lib' and place the downloaded 'selenium-java-.jar' file and add it to your project buildpath.
- package test.example;
- import com.thoughtworks.selenium.DefaultSelenium;
- import com.thoughtworks.selenium.Selenium;
- /**
- * Search Google example.
- *
- * @author aksahu
- */
- public class GoogleTest {
- static Selenium selenium;
- selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com");
- selenium.start();
- selenium.windowMaximize();
- selenium.open("/");
- selenium.type("id=lst-ib", "selenium");
- selenium.click("name=btnK");
- selenium.click("link=Selenium - Web Browser Automation");
- selenium.waitForPageToLoad("30000");
- selenium.stop();
- }
- }
Note: Make sure that you have started the selenium server before running the test.
No comments:
Post a Comment