1, selenium rc+eclipse download installation
Java environment
Official website http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html, Java in this example SE1.8, installed in the D-disk JAVA folder, note the configuration of the environment variables: New variable java_home=d:\java\jdk1.8.0_11, add%java_ in the variable path Home%\bin;.
Verify that Java is installed successfully: Enter java-version in cmd and install successfully if the following Java version information appears
Selenium Rc+junit+eclipse
Eclipse official website http://www.eclipse.org/downloads/, note the operating system (Windows) and the number of system bits (32/64) selection. The higher version now comes with the JUnit plugin, and of course it can be downloaded on the http://junit.org/ itself.
Selenium rchttp://download.csdn.net/detail/fanxinyuan/2695339, the client driver and a selenium server (as shown) can be seen in multiple languages after decompression. We select the Java language client driver in the back.
2, selenium rc+junit environment of the building
Open Eclipse, click File-new-java Project, create a new Java project named Script1, and just start the project contains only the basic SRC folder and the JRE system library, Additional three packages (package) can be built under src: com.util,com.script1,com.data, which are used to store common methods, test scripts, test data, respectively. In addition, selenium RC and JUnit are loaded into the project:
For JUnit, right-click the project Script1-build Path-add Library, pop up the following dialog box, and select Junit-next-junit4-finish.
For selenium RC, right-click Script1-properties, the following dialog box appears, Java buid path (left column)-libraries (right tab)-add external jars, In the dialog box that pops up, select Selenium-java-client-driver.jar,selenium-server.jar,selenium-java-client-driver-sources.jar, and the results are as shown
(For RC You can also directly add the entire folder or library, as long as the role of the line)
3. Scripts
A, using the Selenium IDE recording method to generate an example
IDE is a plugin for Firefox browser, you need to install Firefox first, and then enter the address in Firefox browser https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/ or https://github.com/SeleniumHQ/selenium/wiki/SeIDEReleaseNotes Download the installation Selenium IDE.
Open the Selenium IDE first, click the red dot to open the script recording feature, then enter www.boobooke.com/in Firefox, open the site, and then click Forum.
The recording interface is as follows:
Click File-export Test Case As-java/junit4/remote Control, named Testboobooke.java.
B. Using scripts in Eclipse
When you copy and paste the file into Com.test, an error occurs, and you should be careful to modify the package name in this case, and then change it to pack com.script1.
Package Com.script1;import Com.thoughtworks.selenium.*;import Org.junit.after;import org.junit.before;import Org.junit.test;import static Org.junit.assert.*;import Java.util.regex.pattern;public class TestBoobooke {private Selenium Selenium; @Beforepublic void SetUp () throws Exception {Selenium = new Defaultselenium ("localhost", 4444, "*chrome "," http://www.boobooke.com/"); Selenium.start ();} @Testpublic void Testboobooke () throws Exception {Selenium.open ("/html/home.html"); Selenium.click ("link= http riverbank mitsu optin coax 潧"); Selenium.waitforpagetoload ("30000");} @Afterpublic void TearDown () throws Exception {Selenium.stop ();}}
You can see the file is garbled (link= http riverbank mitsu optin coax 潧), this is because the Selenium IDE encoding mode is utf-8:
The Eclipse IDE is encoded as GBK:
With the other, select the Utf-8 in the following box, link= enter the forum, garbled disappears, and change the file "*chrome" to "*iexploreproxy".
C. Start Selenium server
Open cmd, go to Folder d:\ Sogou high-speed download \ Download \selenium-remote-control-1.0.3\ selenium-java-client-driver-1.0.1 (must first enter Selenium-server.jar path), enter Java-jar Selenium-server.jar, The following interface appears to successfully start the server:
Finally, right-click the project Script1-run As-junit Test and run successfully.
A simple example of selenium (i)