python-selenium web automation test series 1-environment preparation (open the browser, open the URL)

1. Download the browser driver

Taking the Chrome browser as an example, download the browser driver:
Download address of the Chrome browser driver

Insert picture description here
After opening, it will be such a page, and then check the version number of your browser and download the corresponding version driver.
Unzip after download, it will be an exe file
Insert picture description here

2. Install the client python library

pip install selenium

It can be installed directly through pip. If you use pycharm, you can see it after the installation is successful, as shown below
Insert picture description here

3. Write python code and open the browser

from selenium import webdriver

wd = webdriver.Chrome(r'D:\tmp\chromedriver_win32\chromedriver.exe')

Run the program directly, you can successfully open the chrome browser

tips: the code Chrome(r'D:\tof a string r is meant to follow later in the \ deemed not escape

The opening effect is shown below:
Insert picture description here

4. Open the URL

from selenium import webdriver

wd = webdriver.Chrome(r'D:\tmp\chromedriver_win32\chromedriver.exe')

wd.get("https://www.baidu.com/")
wd.get("https://www.baidu.com/")  这句就是打开对应的网址

running result:
Insert picture description here

Published 159 original articles · 22 praises · 90,000+ views

Guess you like

Origin blog.csdn.net/ytuglt/article/details/104271369