04_Selenium Java automated testing environment construction (IDEA)

The IDE used is IDEA.

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

Installation: Follow the default installation and click next.

Verification: After the installation is completed, enter java or java -version in the command line window and if there is a corresponding return, the installation is successful.
Insert image description here
Step 2 : Download and install IDEA
download address: https://www.jetbrains.com/zh-cn/idea/download/#section=windows


Insert image description here
Installation: IDEA downloads the Community version. After downloading, it is an exe file. Install it directly. Select Step 3 as needed : Download the Selenium jar package.

For the java version of Selenium, Selenium is just some jar packages

Selenium official download address: https://www.selenium.dev/downloads/. Sometimes this address cannot be accessed in China. You can usually try it a few times;

Other download addresses: http://selenium-release.storage.googleapis.com/index.html. This is generally available. It lists many versions of selenium. Please pay attention to the version number. The latest one is version 4.0. When downloading, the jar package of selenium java is usually downloaded.
Insert image description here
After downloading, extract it to a certain path and remember this path. You will use this path in step 4.
Insert image description here
Step 4 : Create a java project in IDEA and introduce the Selenium jar package into the project

4.1 Select the menu File—>New—>Project in IDEA, give the project a name such as selenium3java, and select java as the language. It is generally recommended that all lowercase English letters be used for the project name.

4.2 Create a new package under the src of the project. Select the project, right-click and select New—>Package, give the package a name, such as package1

4.3 Create a new java class. Select the newly created package, right-click New—>Java Class, and give the class a name, such as OpenBaidu

4.4 Now introduce all jar packages of selenium into the project.

In IDEA's selection menu File->Project Structure, select Project Settings->Libraries, click the "+" sign (New Project Library), select Java, select the jar package decompressed by WebDriver in step 3 and all jar packages in the libs folder , click Apply.

After successful import, expand the External Libraries folder, as shown below.
Insert image description here
Congratulations, the basic environment is now set up!

Guess you like

Origin blog.csdn.net/dcm1324659876/article/details/132360931