python - using selenium library

selenium is a tool for Web application testing. Selenium tests run directly in the browser, just as real users in the same operation. Supported browsers include IE (7, 8, 9, 10, 11), Mozilla Firefox, Safari, Google Chrome, Opera and so on. selenium is a complete web application testing system that includes test recording (selenium IDE), written and run (Selenium Remote Control) and parallel processing tests (Selenium Grid).
Selenium core Selenium Core Based JsUnit, written entirely in JavaScript, so can be used on any JavaScript-enabled browser.
selenium can simulate the real browser, automated testing tools, support for multiple browsers, reptiles mainly used to solve the problem of rendering JavaScript.

1. Install selenium library

  In the console input: install selenium librarypip install selenium

 

2. Download the browser driver (chrome, for example)

Find the version number of the browser chrome currently used

In http://npm.taobao.org/ find the corresponding drive

Download and unzip the file path to the system environment variables in the path

 

3. Verify that the drive matches

 

 

 No error will prove successful.

 

 

Code Example 4

The following is a simple example code

from selenium import webdriver
from time import sleep

driver=webdriver.Chrome()
driver.set_window_size(1200,1200)
driver.get("https://www.baidu.com/")
one_key=driver.find_element_by_id("kw")
one_key.send_keys("腾讯视频")
sleep(2)
one_click=driver.find_element_by_id("su")
one_click.click()
driver.get("https://v.qq.com/")

driver.close()
driver.quit()

 

 

 

Guess you like

Origin www.cnblogs.com/hyz1900457346/p/12002765.html