摘要: #coding=utf-8 from selenium import webdriver #实例化一个火狐配置文件 fp = webdriver.FirefoxProfile() #设置各项参数,参数可以通过在浏览器地址栏中输入about:config查看。 #设置成0代表下载到浏览器默认下载路径;设置成2则可以保存到指定目录 fp.set_preference("browser.do... 阅读全文
posted @ 2017-04-05 11:25 ForcePush 阅读(3466) 评论(0) 推荐(0) 编辑
摘要: 场景 处理frame需要用到2个方法,分别是switch_to_frame(name_or_id_or_frame_element)和switch_to_default_content() 如何理解这个switch_to_frame(name_or_id_or_frame_element)方法呢?可 阅读全文
posted @ 2017-04-05 10:57 ForcePush 阅读(6619) 评论(0) 推荐(0) 编辑
摘要: #coding:utf-8'''获取测试对象的css属性场景当你的测试用例纠结细枝末节的时候,你就需要通过判断元素的css属性来验证你的操作是否达到了预期的效果。比如你可以通过判断页面上的标题字号以字体来验证页面的显示是否符合预期。当然,这个是强烈不推荐的。因为页面上最不稳定的就是css了,css变动频繁,而且通过属性也不能直观的判断页面的显示效果,还不如让人为的去看一眼,大问题一望即知。''' ... 阅读全文
posted @ 2017-04-05 10:15 ForcePush 阅读(3038) 评论(0) 推荐(0) 编辑
摘要: 场景 对分页来说,我们最感兴趣的是下面几个信息 总共有多少页 当前是第几页 是否可以上一页和下一页 代码 下面代码演示如何获取分页总数及当前页数、跳转到指定页数 阅读全文
posted @ 2017-03-31 10:51 ForcePush 阅读(4007) 评论(1) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*- from selenium import webdriver import time import os dr = webdriver.Chrome() file = os.path.abspath("c:\\Temp\\checkbox.html") #获取文件路径 dr.get(file) # 选择所有的checkbox并全部勾上 che... 阅读全文
posted @ 2017-03-30 14:05 ForcePush 阅读(2205) 评论(0) 推荐(0) 编辑
摘要: from selenium import webdriver driver = webdriver.Chrome() driver.get("http://www.baidu.com") # by link 定位 driver.find_element_by_link_text("新闻").click() # by partial link text定位 driver.find_ele... 阅读全文
posted @ 2017-03-30 13:55 ForcePush 阅读(1038) 评论(0) 推荐(0) 编辑
摘要: #coding=utf-8from selenium import webdriverimport timedriver = webdriver.Chrome()driver.get("http://www.baidu.com")#class 定位driver.find_element_by_css 阅读全文
posted @ 2017-03-30 13:49 ForcePush 阅读(2520) 评论(0) 推荐(0) 编辑
摘要: #coding=utf-8import timefrom selenium import webdriverdriver = webdriver.Chrome()driver.get("http://www.baidu.com")time.sleep(5)#id 定位driver.find_elem 阅读全文
posted @ 2017-03-30 13:43 ForcePush 阅读(2134) 评论(0) 推荐(0) 编辑
摘要: #coding=utf-8from selenium import webdriverdriver = webdriver.Chrome()driver.get("http://www.baidu.com")# 获得输入框尺寸size = driver.find_element_by_id("kw" 阅读全文
posted @ 2017-03-30 11:47 ForcePush 阅读(9595) 评论(0) 推荐(0) 编辑
摘要: #导入模块 from selenium import webdriverfrom selenium.webdriver.common.keys import Keys #启动火狐浏览器driver = webdriver.Firefox() #打开urldriver.get("http://www. 阅读全文
posted @ 2017-03-30 11:41 ForcePush 阅读(4353) 评论(1) 推荐(1) 编辑