自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(23)
  • 收藏
  • 关注

转载 input()与raw_input()的区别

这两个函数均能接收字符串,raw_input()直接读取控制台的输入(可以接收任何类型的输入),input()只能接收合法的python表达式,输入字符串必须使用引号括起来,否则引发一个SyntaxError 。raw_input()将所有输入作为字符串对待,返回字符串类型。而 input()对待纯数字输入时具有自己的特性,返回所输入的数字的类型(int,float)。...

2014-04-24 10:11:00 153

转载 Appium知识技巧收集

1、真机调试打开USB调试模式2、启动脚本提示apk包Could not make a string,是释放string.json出错,由于apk损坏导致,验证是安装到真机上开启APP3、Activity要写对,否则提示不存在Activity,建议写完整名称,完整包名类似com.xxx.xxx.Activity;启动Activity要写对,否则提示XXX never XXX。包名...

2014-04-14 07:18:00 117

转载 智能等待页面元素出现

from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0from selenium.webdriver.support import expe...

2014-04-14 06:46:00 250

转载 图片相似度对比

#sudo pip install PILdef pil_image_similarity(filepath1, filepath2):from PIL import Imageimport mathimport operatorimage1 = Image.open(filepath1)image2 = Image.open(filepath2)# image1 = get_t...

2014-04-12 19:33:00 471

转载 【Selenium11】获取测试对象的内容、属性、及状态

1、获取测试对象的内容和属性  使用element.attribute()方法获取dom元素的内容  获取测试对象的属性能够更好的定位对象,比如页面上有很多class都是'btn'的div,而目标是其中1个有具有title属性的div,由于selenium-webdriver不支持直接使用title来定位对象,所以只能先把所有class是btn的div都找到,然后遍历这些div,...

2014-04-08 07:32:00 170

转载 【Selenium10】处理对话框

页面上弹出的对话框若是基于iframe,需要进行switch_to_frame操作,若是div形式,则处理更简单操作有:打开对话框、关闭对话框、操作对话框中的元素用到的HTML文档 <html> <head> <meta http-equiv="content-type" content="tex...

2014-04-08 07:01:00 106

转载 【Selenium9】操作按钮

1、处理按钮组button group  首先找到button group的包裹view,然后层级定位查找具体按钮用到的HTML文档 <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /&...

2014-04-08 06:41:00 116

转载 【Selenium8】cookie处理

coding=utf-8from selenium import webdriverimport timedriver=webdriver.Firefox()driver.get('http://www.baidu.com')cookie=driver.get_cookies() #获取cookie信息print cookiedriver.delete_all_cooki...

2014-04-07 19:44:00 72

转载 【Selenium7】鼠标事件

鼠标事件相关类:ActionChains类,主要方法有  key_up:模拟按键弹起  key_down:模拟按键按下  click:点击  send_keys:传递值  double_click:鼠标左键双击  click_and_hold:鼠标左键点击后保持  release:鼠标左键弹起,与click_and_hold结合使用  move_to_el...

2014-04-07 19:36:00 74

转载 【Selenium6】下拉框、弹出框、滚动条操作

1、处理下拉框所用HTML文档<html><body><select id="ShippingMethod" onchange="updateShipping(options[selectedIndex]);" name="ShippingMethod"><option value="12.51">UPS N...

2014-04-07 19:27:00 481

转载 【Selenium5】文件的上传与下载

1、文件的上传coding=utf-8from selenium import webdriverimport timeimport osbrowser=webdriver.FireFox()file_path='file:///'+os.path.abspath('upload_file.html')browser.get(file_path)browser.find_el...

2014-04-07 19:03:00 77

转载 【Selenium4】操作测试对象

1、常用方法:点击对象、在对象上模拟按键输入、清除对象的内容、获取元素的文本、提交表单、获得属性值coding=utf-8from selenium import webdriverimport timebrowser=webdriver.FireFox()browser.get('http://www.baidu.com')browser.find_element_by_i...

2014-04-07 18:42:00 231

转载 【Selenium3】测试对象的定位

1、目的  操作对象、获得对象的属性值、获得对象的text、获得对象的数量2、单个对象定位方法:id、name、tag name、class name、CSS、XPath、Link Text、Partical Link Text用到的HTML文档 <html> <head> <meta http-equiv="conte...

2014-04-07 17:27:00 161

转载 【Selenium2】简单浏览器操作

#打印URLcoding=utf-8from selenium import webdriverimport timebrowser=webdriver.FireFox()url='http://www.baidu.com'browser.get(url) #通过操作get()得到URLprint 'Title of current page is %s'%(browser.ti...

2014-04-07 13:15:00 90

转载 【Selenium1】第一个SeleniumWebdrive脚本

coding=utf-8from selenium import webdriverimport timebrowser=webdrive.FireFox() #操作FireFox浏览器,新建实例browser.get('http://www.baidu.com') #打开URL用get()函数time.sleep(1) #休眠1sprint driver.title #打印...

2014-04-07 13:00:00 123

转载 Python读取Excel数据

import xlrddata=xlrd.open_workbook('TSMdata.xlsx') #Excel文档存储路径:C:\Python27table=data.sheets()[0] #按索引获取sheetnrows=table.nrows #行数ncols=table.ncols #列数colnameindex=0 colnames=table.row_va...

2014-04-03 10:12:00 173

转载 博客园首页登陆,获取HTML文档

import reimport cookielibimport urllibimport urllib2def printDelimiter(): #打印分割线 print '-'*80printDelimiter()print '[preparation] using cookiejar & HTTPCookieProcessor to antomatically ha...

2014-03-26 06:33:00 275

转载 登录百度首页的HTTP请求过程具体分析,重点为包体数据

https://passport.baidu.com/v2/api/?login,Post请求该URL的包体数据分析staticpage=http%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fv3Jump.html #编码后的URL,原URL:http://www.baidu.com/cache/user/html/v3Jump...

2014-03-24 16:38:00 1977

转载 实现URL的解码

import urllibencodedUrl='http%3A%2F%2Fwww.baidu.com%2Fcache%2Fuser%2Fhtml%2Fv3Jump.html' #登录百度首页抓取到的一条Post数据为编码后的URLdecodedUrl=urllib.unquote(encodedUrl) #URL解码实现:urllib.unquote()...

2014-03-24 10:48:00 82

转载 模拟登陆百度首页完整版

import reimport cookielibimport urllibimport urllib2import optparsedef checkAllCookiesExist(cookieNameList,cookieJar): cookiesDict={} for eachCookieName in cookieNameList: cookiesD...

2014-03-23 17:59:00 177

转载 获取访问网页返回的cookie,打印每个cookie的域值

#模拟登陆百度空间,获得最开始登陆百度空间网页返回的cookieimport cookielib,urllib,urllib2loginUrl='http://hi.baidu.com/motionhouse'cj=cookielib.CookieJar() #新建CookieJar实例,用于保存cookieopener=urllib2.build_opener(urllib2.H...

2014-03-23 15:13:00 645

转载 实现带cookie的HTTP的Post请求

上篇实现了获取cookie,现在将已经获得的cookie,在提交HTTP的Post请求时,也发送出去,即实现带cookie的HTTP的Post请求import cookielib,urllib,urllib2#第一次请求URLbaiduSpaceEntryUrl='http://hi.baidu.com/motionhouse' #百度空间URLcj=cookielib.C...

2014-03-23 15:00:00 1116

转载 登陆百度空间,获得网页返回的cookie

#模拟登陆百度空间,获得最开始登陆百度空间网页返回的cookieimport cookielib,urllib2loginUrl='http://hi.baidu.com/motionhouse'cj=cookielib.CookieJar() #新建CookieJar实例,用于保存cookieopener=urllib2.build_opener(urllib2.HTTPCook...

2014-03-23 14:47:00 216

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除