Java+selenium Environment Construction

Source: Internet
Author: User

This article is only for the purpose of documenting the environment, convenient for you to view later.

First, build maven in eclipse

1. Install maven

Unzip the apache-maven-3.5.0 into the C packing directory

Configure The MAVEN environment to change

maven_home:c:\apache-maven-3.3.9
MAVEN:%maven_home%\bin
Maven_opts:-xms256m-xmx512m
at the front of the path, add: %maven%;

Verify that maven is installed successfully

Cmd->mvn-version

The following interface appears for success

2.maven Configuration

Set up manual warehouse maven_repository

Give Maven adds a local repository:
in the Configure settings.xmlin the Conf folder in the Maven installation path :
Find the Localrepository comment line in the text and add the following:
<localRepository>E:\maven-dependcies</localRepository>

Give Maven configuration Mirror:
Mirror is a mirror that provides a convenient way to switch remote warehouse addresses.
in the Configure settings.xmlin the Conf folder in the Maven installation path :
Find The <mirrors> line in the article and add it as follows:

<mirror>

<id>nexus-aliyun</id>

<mirrorOf>*</mirrorOf>

<name>nexus aliyun</name>

<url>http://maven.aliyun.com/nexus/content/groups/public</url>

</mirror>

3. Installing the Maven plugin in eclipse

Open Eclipse, go to help ->install New software ...
Point ADD button Input:
M2e
Http://download.eclipse.org/technology/m2e/releases

then click Next until the installation is complete.
Set MAVEN program associated with the Maven plugin :
Select window-->preferences-->maven--installations menu item in the Eclipse menu bar , point
Click Add to select The specific installation directory for Maven

to set up a custom local warehouse :
Select window-->preferences-->maven--usersettings menu item in the Eclipse menu bar , repair
change to our custom warehouse location under the settings.xml file, and then click the OK button.

New maven project

Second,Java +selenium environment configuration

syntax for Selenium3.0:

method One:

Put the latest geckodriver.exe in the java installation directory/bin directory

Webdriver Driver = new Firefoxdriver ();

Method Two:

if geckodriver.exe is placed in an arbitrary directory, such as C:\webdriver\geckodriver.exe

String firefoxdriver = "C:\\webdriver\\geckodriver.exe";

System.setproperty ("Webdriver.gecko.driver", firefoxdriver);

Webdriver Driver = new Firefoxdriver ();

2, Google browser

method One:

Put the latest chromedriver.exe in the java installation directory/bin directory

Webdriver Driver = new Chromedriver ();

Method Two:

if geckodriver.exe is placed in an arbitrary directory, such as C:\webdriver\chromedriver.exe

String chromedriver = "C:\\webdriver\\chromedriver.exe";

System.setproperty ("Webdriver.gecko.driver", chromedriver);

Webdriver Driver = new Chromedriver ();

Ie:

Webdriver to use IE browser need to download InternetExplorerDriver.exe, according to the version of the browser download 32 or The driver of the position.

How to do it in accordance with Google browser

Summary:

Driver.exe version is incompatible with the browser version

http://blog.csdn.net/wangxh_btnn/article/details/53466804

Selenium version is incompatible with Driver.exe version

The preparation tools are as follows:
JDK installation package: JDK1.8 and above
Eclipse Compression Pack: http://www.eclipse.org/downloads/
Selenium Compressed Package: http://code.google.com/p/selenium/downloads/list ( maven recommended) below)

1) Create a new maven project -- open pom.xml

2) Baidu maven repository search Selenium Java

3) find Selenium Java replication maven script code into the new pom.xml

<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>Selenium-java</artifactid>

<version>3.3.1</version>

</dependency>

modifying the JDK version

Right-click JRE System library[javase-1.8]->properties

Once the environment is created, you can then create the automation script

Java+selenium 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.