java+selenium automated test environment deployment
Step 1: Check the Google version
It is recommended to use the latest version. Enter the place as shown in the figure to view and upgrade the version:
If Google cannot update, it may be caused by QQ Computer Manager or 360 software .
1. Upgrade in the computer manager.
2. Download the version you want according to google's chromedriver file .
3. It is recommended to uninstall the latest version and reinstall.
Because we have to download google's chromedriver file according to our own version. We can go to google's chromedriver file to download , this website downloads the version resources you need. Because mine is 87.0.4280.88, so download the version in the red circle.
Because of my window system, download the window according to your system version.
1. It does not matter if your Google version is window64 bit, it is compatible.
2. The corresponding version only needs to correspond to the front, and the number after the last decimal point is not the same. For example, 87.0.4280.88, 88 can be different.
Step 2: Put the chromedriver.exe file in the bin file of the JDK.
First of all, you have to enter java -version in cmd . If the corresponding version number does not appear, it proves that your environment variables have not been set, and you have to set your jdk environment variables.
1. Check the JDK path.
Enter cmd in java -verbose can view the version of jdk:
as shown:
Since prevent people installed multiple versions of jdk and jre , I was one of them, we have other ways to view JDK path. As shown in the figure, click the red circle to get it out.
You can see our jdk path from here.
2. Then unzip the chromedriver_32 file we just downloaded
3. Put the chromedriver.exe file under the bin file in your jdk path:
Step 3: implement environment deployment
1. Create a new Java project.
as the picture shows:
2. Right-click on the red circle as shown in the figure
2. Select the red circle
3. Select all jars in the lib file, and then select Open, as shown in the figure.
The address of the lib file is as follows, I set 0 points, which can be downloaded immediately:
lia.zip file
4. Then select ok, as shown in the figure.
Step 4: Let's create a new Java file for testing.
After creating a new file, enter the code as shown in the figure.
code show as below:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver=new ChromeDriver();
driver.get("https://www.baidu.com");
driver.findElement(By.name("wd")).sendKeys("新梦想测试");
driver.findElement(By.id("su")).click();
}
}
Then we look at the effect and click to run the code.
We can see that the operation was successful. The system automatically opened Google and entered the search with Baidu:
Congratulations, the environment deployment is successful.