Environment construction
first, the development environment:
1, JDK1.6
2. Eclipse:Version:Kepler Service Release 1,:http://www.eclipse.org/downloads/
3, Selenium:selenium-java-2.39.0.zip,:http://code.google.com/p/selenium/downloads/list
Unpack the Selenium-java package, which contains four parts, such as:
Second, create a new Java Project:
1. Create a Java project:
2, then the above extracted files copied to the new project directory, directory structure such as:
3. Add build path, project directory right-->build path--> config build Path-->java build Path-->libraries-->add JARs, Add all the jar packages under the Libs folder and add Selenium-java-2.48.2-srcs.jar and Selenium-java-2.48.2.jar
3, add after the directory structure, such as, more referenced Libraries, here is the above step added to the jar package:
now that the environment is ready to work, here is a simple little example to write.
4. Create a new test class under SRC, such as:
5, add code, implementation: open Baidu, and then in the Baidu search box input HelloWorld, click the Search button, close the browser.
ImportOrg.openqa.selenium.By;ImportOrg.openqa.selenium.WebDriver;ImportOrg.openqa.selenium.WebElement;Import org.openqa.selenium.firefox.*;PublicClassTestClass {public static void< Span style= "color: #000000;" > main (string[] args) {// If Firefox is not installed on the C drive by default, you need to make its path Span style= "color: #008000;" >//system.setproperty ("Webdriver.firefox.bin", "D:/program Files/mozilla firefox/ Firefox.exe "); Webdriver Driver = new Firefoxdriver (); Driver.get (" http://www.baidu.com/"); Driver.manage (). window (). Maximize (); Webelement txtbox = driver.findelement (By.name ("WD" ); Webelement btn = driver.findelement (by.id ("su"
Then directly right-click-->run As-->java application can see the effect.
Test work--SELENIUM2 Environment construction