The following describes how to build a script compiling environment Using Selenium test in eclipse-JUnit,
Make sure that you have installed JDK and eclipse.
1. First download the required file
Download the jar package required by selenium-RC from the Internet, which can be downloaded from the official website http://seleniumhq.org/download/or from the Internet.
I downloaded a selenium-remote-control-1.0.3.zip.
:
Http://download.csdn.net/detail/spring292713/4456349
Download the jar package of junit4.8 because an error is reported when I use the JUnit package that comes with eclipse. java. Lang. noclassdeffounderror: JUnit/framework/testcase;
It will be okay after you replace JUnit downloaded from the official website.
2. Create a test project and import relevant jar files.
Open eclipse and create a Java project. Right-click the project name and choose build path> Add libraries> User library, click User library> newin the dialog box to add the selenium-java-client-driver.jar under selenium-Java-client-driver-1.0.1 in selenium-remote-control-1.0.3.zip to the library;
Similarly, add the junit-4.7.jar under the next JUnit to the library,
Then, import the two jar files to classpath;
4. Set selenium resource file connection
Select a project, right-click build path-> link source, select the selenium-Java-client-driver-1.0.3 folder under selenium-remote-control-1.0.1, and finish.
5. Create a new test class and enter the test code as follows:
package com.example.Open;import com.thoughtworks.selenium.*;public class Test extends SeleneseTestCase{public void setUp() throws Exception {setUp("http://www.baidu.com");} public void testUntitled()throws Exception {selenium.open("/");}}
6. Start selenium-Server
Go to selenium-server-1.0.3 under selenium-remote-control-1.0.3 in cmd,
Run the Java-jar selenium-server.jar to start.
For convenience, you can create a batch file to start selenium-server. My batch file:
Java-jar D: \ selenium-remote-control-1.0.3 \ selenium-server-1.0.3 \ selenium-server.jar
Run the test class !!
The following result is displayed, indicating that the operation is successful !!