Depth Selenium automated testing environment to build (java articles)

In the previous article, we introduced the Selenium tool, explained how it works, this article started, it entered into a specific part of the operation, make sure first of all is to build automated test environment, this article on automated testing environment for Selenium Java to build a detailed introduction.

The IDE is Eclipse.

Step 1: Because it is based on Java, so we must first download and install the JDK (Java Development Kit)

下载JDK:http://www.oracle.com/technetwork/java/javase/downloads/index.html

Installation: In accordance with the default installation all the way to the point next to it.

Verify: After installation is complete, the command input window corresponding java -version java or return to the installation was successful.

 

Step 2: Download and installation Eclipse

Download: Download Eclipse from here

http://www.eclipse.org/downloads/

Installation: After downloading Eclipse is a zip bag, put it in D drive or what you like, you can extract the following path, and no special installation. Unzip a folder named eclipse, which has a eclipse.exe file, double-click to run it. For ease of use the best set up a desktop shortcut.

 

Setting the Eclipse workspace: When you first start Eclipse will be prompted to set up a workspace workspace, the work space is used to store java project created behind, webdriver scripting behind will be placed in the workspace. Specify a folder on it, not too deep, such as on the D: \ workspace Step 3: Download Selenium jar package

For java version of Selenium is, Selenium tool that some jar package.

selenium Official Download: http: //www.seleniumhq.org/download/, sometimes this address in the country can not be accessed, usually try several times on it;

 

After downloading unzip it to one path, and remember this path in step 4 will use this path.

 

步骤4:在Eclipse中创建一个java项目,把Selenium的jar包引入到项目中

4.1 在Eclipse中选择菜单File--》New--》Java Project,给项目起个名字比如selenium3java,项目名称一般建议全部用小写英文字母。

4.2 在项目下新建一个包。选中项目,右键选择New--》Package,给包起个名字,如package1

4.3 新建一个java的类。选中新建的包,右键New--》Class,给类起个名字,如OpenBaidu

4.4 现在将selenium的所有jar包引入到项目中来。

选中项目,在右键菜单中选择Build Path --》Configure Build Path…,选择Libraries ,点击Add External JARs… 选择步骤3中WebDriver解压的jar包及libs文件夹下的所有jar包,点击 Apply and Close。

成功导入后,项目下会多一个Referenced Libraries文件夹,如下图

 

恭喜,至此基本的环境搭建就完成了!

 

 

在下一篇中,我们就可以开始写第一个Selenium Java的自动化脚本了。

Guess you like

Origin www.cnblogs.com/cs1188/p/11512267.html