November 15, the concept of automated testing has a preliminary understanding, because the course is open class, so the environment needs us in advance at home, in the process of building the environment is indeed some difficulties, all kinds of Baidu debugging finally set up the environment, the following part of the content is reproduced, good not wordy, Directly on the selenium environment to build the steps.
Environment: win7+selenium+java+eclipse+firefox28.0
Step One: Install the JDK (my JDK version 1.7) and configure the environment variables.
Install JDK Select two installation prompts during installation of the installation directory. The first is to install the JDK, and the second is to install the JRE. The recommended two are installed in a different folder in the same Java folder. (cannot be installed in the root directory of the Java folder, the JDK and JRE are installed in the same folder error)
As shown in the following figure 2
1: Install the JDK randomly select the directory only by the default installation directory \java before the directory modification can
2: Install jre→ change →\java directory and install JDK directory same
Note: If no installation directory requirements, can be the default settings. No need to make any changes, two times all directly point to the next step. 3
Configure environment variables after installing JDK → properties → advanced system settings → advanced → environment variables
4
system variable → new java_home variable.
Variable value fill in the installation directory of JDK (I am E:\Java\jdk1.7.0)
5
System variable → find Path variable → edit
Enter the%java_home%\bin;%java_home%\jre\bin at the end of the variable value;
(Note that the value of the variable at the end of the path is not, if not, first enter the number and then enter the code above) 6
system variable → new CLASSPATH variable
Variable value fill in.; %java_home%\lib;%java_home%\lib\tools.jar (Note that there is a point at the front)
System Variable Configuration complete 7
Verify that the configuration successfully runs CMD input java-version (there are spaces between Java and-version)
Displaying version information as shown in the illustration indicates a successful installation and configuration.
Step Two: Install Eclipse (the installation process is not described here)
Step Three: Build the Environment (this Part reprint http://www.cnblogs.com/puresoul/p/3483055.html)
first, development environment:
1, JDK1.7
2, Eclipse:Version:Kepler Service Release 1
3, Selenium:selenium-java-2.39.0.zip
Unpack the Selenium-java package, which contains four parts, as shown below:
Second, create a new Java Project:
1, and then the above extracted files copied to the new project directory, the directory structure as shown below:
2. Add build path, project directory right key-->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.39.0 and Selenium-java-2.39.0-srcs
3, after the addition of the directory structure as shown below, more referenced libraries, here is the above step added to the jar package:
4, the related Webdriver source code:
Now that the environmental work is ready, let's write a simple little example.
third, under SRC New test class, the following figure:
Test code:
Package Com.selenium.Glen;
Import Org.openqa.selenium.By;
Import Org.openqa.selenium.WebDriver;
Import org.openqa.selenium.WebElement;
Import org.openqa.selenium.firefox.*; public class Testhelloworld { public static void Main (string[] args) { & nbsp //If Firefox does not default to install in C, it needs to develop its path
//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")); txtbox.seNdkeys ("Glen"); Webelement btn =
Driver.findelement (By.id ("su"));
Btn.click ();
driver.close ();
}}