Getting started with selenium automation

Posted May 28, 20201 min read

  1. chromedriver download
    http://npm.taobao.org/mirrors...

You need to download the corresponding driver according to the current version of chrome(chrome://version /), and the downloaded driver will be placed in the root directory of your python installation
The following code simply implements a search function on the Baidu homepage

from selenium import webdriver
import time

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
driver.find_element_by_id('kw'). send_keys('mytest')
driver.find_element_by_id('su'). submit()
time.sleep(20)
driver.close()
  1. Search elements
    The find \ _element \ _by \ _name method returns the first element that matches the name attribute value

Continuous learning and updating ...