Step 1: Download the selenium,
selenium-server-standalone-2.28.0.jar (31.5MB).
Step 2: Download the junit-4.3.1. jar, http://mirrors.ibiblio.org/pub/mirrors/maven2/junit/junit/4.3.1/junit-4.3.1.jar
Step 3: Open the command prompt and run as follows,
“java -jar selenium-server-standalone-2.28.0.jar”
Image may be NSFW.
Clik here to view.Step 4: Open the eclipse and create the project, Image may be NSFW.
Clik here to view. Step 5: Create the java project named “Selenium” and create the class named “JavadomainTest.java” and paste the below code,
import org.junit.Test; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium; public class JavadomainTest{ @Test public void jdtesting() throws InterruptedException{ Selenium selenium = new DefaultSelenium("localhost",4444,"firefox","http://google.com"); selenium.start(); //starting selenium instance selenium.open("/"); selenium.windowMaximize(); selenium.windowFocus(); selenium.type("//*[@id='gbqfq']","javadomain.in"); selenium.click("//*[@id='gbqfb']"); Thread.sleep(20000); selenium.click("//*[@id='rso']/li[1]/div/h3/a/em"); Thread.sleep(80000); selenium.close(); //to close the browser selenium.stop(); //to stop selenium instance } }
Step 6: Rightclick on the project -> Build path -> Configure build path -> Libraries -> Add external jars -> (browse the location of downloaded selenium and junit jar file) -> ok.… Read more.....
The post Selenium server standalone example appeared first on Javadomain.