Selenium Java Environment setup

Source: Internet
Author: User

SELENIUM2 (webdirver) Getting Started Environment Building (Java Edition)

First, the development environment:

1, JDK1.6

2. Eclipse:Version:Kepler Service Release 1,:http://www.eclipse.org/downloads/

3, selenium:selenium-java-2.52.0.zip,:http://docs.seleniumhq.org/download/

Unpack the Selenium-java package, which contains four parts, such as:

  

Second, create a new Java Project:

1, then the above extracted files copied to the new project directory, directory structure such as:

  

2. Add build path, project directory right click-->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, add after the directory structure, such as, more referenced Libraries, here is the above step added to the jar package:

  

4, the source of related webdriver:

  

Now that the environment is ready to work, here is a simple little example to write.

III. Create a new test class under SRC, such as:

The code below, mainly open Baidu, and then enter Glen in the Search box, click the Search button, close the browser.

1PackageCom.selenium.Glen;23ImportOrg.openqa.selenium.By;4ImportOrg.openqa.selenium.WebDriver;5ImportOrg.openqa.selenium.WebElement;6Import org.openqa.selenium.firefox.*;78PublicClassTesthelloworld {910PublicStaticvoidMain (string[] args) {1112//If Firefox is not installed by default on the C drive, you need to set its path13//System.setproperty ("Webdriver.firefox.bin", "D:/program Files/mozilla firefox/firefox.exe");Webdriver Driver =NewFirefoxdriver ();Driver.get ("http://www.baidu.com/");16 17  Driver.manage (). Window (). Maximize (); 18 19 webelement txtbox = driver.findelement (By.name ("WD" 20 txtbox.sendkeys ("Glen"  22 webelement btn = driver.findelement (by.id ("su" 23  Btn.click ();  25  Driver.close ();  27 }28 29}              

Then right-click-->run As-->java application to see the effect.

Selenium Java Environment setup

Related Article

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.