理解

web应用程序测试工具(录制、编写、运行、测试并行处理)
api 编辑 并行测试
【自动化测试】Selenium_计算机脚本(client)-驱动-浏览器(server)-服务器
【自动化测试】Selenium_python_02

2.0版本升级

【自动化测试】Selenium_chrome_03

示例

【自动化测试】Selenium_python_04【自动化测试】Selenium_mysql_05

配置环境

【自动化测试】Selenium_mysql_06

驱动

【自动化测试】Selenium_python_07【自动化测试】Selenium_mysql_08
版本号对应下载驱动
【自动化测试】Selenium_python_09【自动化测试】Selenium_计算机_10保存到本地
【自动化测试】Selenium_mysql_11【自动化测试】Selenium_chrome_12火狐驱动
girhub【自动化测试】Selenium_python_13解压缩保存
【自动化测试】Selenium_python_14
【自动化测试】Selenium_python_15

测试

【自动化测试】Selenium_计算机_16

ide

【自动化测试】Selenium_chrome_17
录制
【自动化测试】Selenium_计算机_18失败是由于广告算法推荐导致没有内容重现
【自动化测试】Selenium_chrome_19导出脚本
【自动化测试】Selenium_mysql_20【自动化测试】Selenium_计算机_21

ide只需一个

,可以访问chrome,改脚本就行
【自动化测试】Selenium_mysql_22

实验

【自动化测试】Selenium_mysql_23【自动化测试】Selenium_python_24点点点
【自动化测试】Selenium_mysql_25脚本分析忽略鼠标滑过
【自动化测试】Selenium_python_26

常用类库安装

验证urllib库是否安装

C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> import urllib.request
>>> urllib.request.urlopen('http://www.baidu.com')
<http.client.HTTPResponse object at 0x000001D702358048>
>>> import re

安装requests

C:\Users\wangwei>pip.exe install requests

C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get('http://www.baidu.com')
<Response [200]>

安装selenium

C:\Users\wangwei>pip.exe install selenium

安装chromedriver

【自动化测试】Selenium_python_27
https://npm.taobao.org/mirrors/chromedriver/
【自动化测试】Selenium_计算机_28【自动化测试】Selenium_计算机_29【自动化测试】Selenium_mysql_30

安装FireFox WebDriver

https://github.com/mozilla/geckodriver/releases/
【自动化测试】Selenium_mysql_31
【自动化测试】Selenium_计算机_32

测试

>>> from selenium import webdriver
>>> driver=webdriver.Chrome()

DevTools listening on ws://127.0.0.1:9973/devtools/browser/4e81b3a4-c889-430c-8948-1bbecb3c2933
[33028:51916:0507/222623.575:ERROR:browser_switcher_service.cc(238)] XXX Init()
>>> driver.get('http://www.baidu.com')

【自动化测试】Selenium_mysql_33

phantomJS无界面浏览器

【自动化测试】Selenium_python_34

C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> driver=webdriver.PhantomJS()
C:\Users\wangwei\Anaconda3\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
  warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
>>> driver.get('http://www.baidu.com')
>>> driver.page_source

【自动化测试】Selenium_chrome_35

lxml

C:\Users\wangwei>pip.exe install lxml

beautifulsoup4

C:\Users\wangwei>pip.exe install beautifulsoup4



C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> soup=BeautifulSoup('<html></html>','lxml')
>>>

pyquery


C:\Users\wangwei>pip.exe install pyquery


C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyquery import PyQuery as pq
>>> doc =pq('<html>Hello</html>')
>>> result=doc('html').text()
>>> result
'Hello'
>>>

pymysql

C:\Users\wangwei>pip.exe install pymysql


C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
>>> conn =pymysql.connect(host='localhost',user='root',password='root',port=3306,db='mysql')
>>> cursor=conn.cursor()
>>> cursor.execute('select * from db')
2

安装flask

C:\Users\wangwei>pip.exe install flask


C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>

安装Django

C:\Users\wangwei>pip.exe install django

C:\Users\wangwei>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django

安装Jupyter

C:\Users\wangwei>pip.exe install jupyter
启动notebook
C:\Users\wangwei>jupyter notebook

【自动化测试】Selenium_mysql_36【自动化测试】Selenium_mysql_37