Python自动化
文章平均质量分 90
Baron Davis
I am a green hand.
展开
-
pymysql通过ssh方式进行数据库操作
由于阿里云服务器安全组规则没有开放3306端口,我们不能直接通过3306端口进行访问,但是可以采用ssh的方式登录mysql数据库,代码如下# _*_ coding:utf-8 _*_import pymysqlfrom sshtunnel import SSHTunnelForwarder# 数据库配置信息host = '192.168.1.1'user = 'username'dbpassword = 'password'dbname = 'testdb'class Execut原创 2020-08-12 23:27:50 · 915 阅读 · 1 评论 -
Python的数据库操作之pymysql
准备工作// An highlighted blockpip3 install pymysql数据库连接connect() 方法声明一个MySQL连接对象db。// An highlighted blockdb = pymysql.connect("host", "用户名", "密码", "库名")游标cursor() 方法获得MySQL的操作游标,利用游标来执行SQL语句。// An highlighted blockcursor=db.cursor()增// An high原创 2020-06-16 20:47:37 · 203 阅读 · 0 评论 -
测试自动化体系的搭建
语言和框架Python做自动化测试,首选的开发语言是Python,因为这门语言简洁明了,容易上手。下载官网下载https://www.python.org/安装按照操作指导安装配置环境变量参考JDK环境变量配置框架结构做接口自动化,我选择的框架是python+unittest+requests+BeautifulReport。python是开发语言;unittest是pyt...原创 2020-04-02 21:05:46 · 2247 阅读 · 0 评论 -
Python+Selenium自动化之上传文件
1.input标签众所周知,input标签是可以直接send_keys的,这里也不例外,来看代码示例:示例网址:http://www.sahitest.com/demo/php/fileUpload.htm代码:# -*- coding: utf-8 -*-from selenium import webdriverdriver = webdriver.Firefox()drive...原创 2019-10-23 10:48:59 · 251 阅读 · 0 评论 -
Python+Selenium自动化之提取图片信息
Python+Selenium自动化之提取图片信息from PIL import Imageimport pytesseract#上面都是导包,只需要下面这一行就能实现图片文字识别text = pytesseract.image_to_string(Image.open('E:\example4.jpg',),lang='chi_sim')#设置为中文文字的识别#text = pytes...原创 2019-10-23 10:47:24 · 1198 阅读 · 0 评论 -
Python+Selenium自动化之下拉列表使用方法
Python+Selenium自动化之下拉列表使用方法1.通过selenium.webdriver.support.ui的Select进行定位下拉菜单如下图:定位代码(选择Male):from selenium.webdriver.support.ui import Select通过index进行选择Select(driver.find_element_by_id(“gender”)...原创 2019-10-23 10:45:12 · 1271 阅读 · 0 评论