selenium初识:selenium的安装及简单实现百度搜索

selenium:流行的开源跨平台的web自动化测试工具

 

环境:macos 10.15.6

浏览器:Chrome

 

步骤一:安装python(这样安装的python不与系统冲突,python默认安装pip,没有的话执行sudo easy_install pip)

brew install python

sudo easy_install pip

 

python3 使用python

pip3 使用pip

 

步骤二:安装selenium

 

pip3 install selenium  python安装selen库

brew cask install chromedriver 安装Chrome驱动

 

实现简单搜索

 

baidu.py

 

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

url='https://www.baidu.com'
chrome = webdriver.Chrome()
chrome.get(url)
chrome.find_element_by_id('kw').send_keys('hello selenium')
chrome.find_element_by_id('kw').send_keys(Keys.ENTER)

 

posted @ 2020-09-02 10:05  豆浆D  阅读(116)  评论(0编辑  收藏  举报