Test work--SELENIUM2 Environment construction

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.