selenium IDE--录制和回放脚本
1 selenium IDE--录制脚本
准备工作:firefox 浏览器安装了selenium IDE 插件
实例:打开百度搜索“软件测试”
- firefox浏览器打开网址:https://www.baidu.com/
- 点击浏览器插件【selenium】图标,弹出selenium IDE 录入界面,Base URL设置为:https://www.baidu.com/(默认为录制状态)
- 在步骤1中,直接输入“软件测试”关键字,点击【百度一下】进行搜索
- selenium IDE 点击【停止录制】红点,如下图:table中记录了我们刚才的操作

2 selenium IDE--回放脚本
- 回放脚本时需要先开启selenium服务,进入jar包目录,输入cmd命令:java -jar selenium-server-standalone-2.40.0.jar
- selenium IDE 点击【回放用例】按钮,如下图1:
- 保存为baidu_search.py脚本(附录脚本),如下图2:


# -*- coding: utf-8 -*-
'''
时间:2015.04.16
作者:chenfenping
功能:百度搜索软件测试实例演示selenium IDE的使用
'''
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re class baidu_search(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "https://www.baidu.com/"
self.verificationErrors = []
self.accept_next_alert = True def test_11(self):
driver = self.driver
# open | / |
driver.get(self.base_url + "/")
# click | id=kw |
driver.find_element_by_id("kw").click()
# type | id=kw | 软件测试
driver.find_element_by_id("kw").clear()
driver.find_element_by_id("kw").send_keys(u"软件测试")
# click | id=su |
driver.find_element_by_id("su").click() def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException, e: return False
return True def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors) if __name__ == "__main__":
unittest.main()
selenium IDE--录制和回放脚本的更多相关文章
- Selenium----Selenium简单介绍以及Selenium IDE环境搭建,脚本录制
1.selenium简单介绍 心得:作为一个新手开始了解这个工具,打算从录制脚本开始学习,“录制,看,学习,写”,总结网友说得打算先使用Selenium IDE录制学习,再使用Selenium RC开 ...
- Android自动化测试之MonkeyRunner录制和回放脚本
Android自动化测试之MonkeyRunner录制和回放脚本(十一) 分类: 自动化测试 Android自动化 2013-02-22 10:57 7346人阅读 评论(2) 收藏 举报 andro ...
- 1.2 selenium IDE录制脚本
1.打开Firefox浏览器中 selenium IDE
- selenium IDE录制脚本和自定义脚本-->Katalon Recorder(二)
selenium IDE提供了两种生成脚本的方式:录制脚本和自定义脚本 录制脚本:1.打开firefox空白标签,在标签上输入需要录制脚本的网址:2.打开selenium IDE界面中的录制按钮(圆形 ...
- Selenium IDE录制脚本时弹出窗口的完美处理
很多朋友录制脚本时新打开弹出窗口后无法定位元素,我也遇到同样的问题,国内没有什么好的资料,于是就阅读英文,不断尝试,感觉那个selectWindow(title)什么就是个坑,我用这种方法成功处理后得 ...
- Selenium IDE录制脚本
一.当Selenium IDE中Format没有转换格式时,操作:Options—Options...—勾选Enable experimental features
- selenium IDE录制
一. 安装 可以用Firefox打开https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/,在这里边找到和当前firef ...
- selenium ide 录制回放link链接报错
回放是出现以下错误: 也就是回放点击打开新的链接时出现这个错误, 这个问题说的是 点击此链接会新打开一个窗口 selenium1是不支持多窗口切换的 因此会卡在这里,也就录制不支持这个操作,但是很多书 ...
- 1.3 selenium IDE录制脚本转换为其他代码格式
1.在seleniumIDE录制框中点击Options->options... 在Enable experimental features前打对勾,点击确定.
随机推荐
- libharu 源码编译 VS2010
最近项目中接过了一个libharu PDF 开源库的锅,哈哈.于是就自己编译了一套libharu 的MFC下的静态库和动态库. 编译libharu需要用到zlib库和libpng库,libpng库又依 ...
- 复杂的databinding接受Ilist作为数据源
Combobox控件绑定数据源时,List<T>可以作为数据源,但是List<String,Object> 不存在,我们有时候需要用Dictionary<String,o ...
- 【转】HTML5新增元素兼容旧浏览器方法
ref:http://www.jb51.net/html5/163906.html 问题:如何让IE8-兼容这些标签?(需要设计JS中的DOM) 代码如下: <span style=" ...
- DXperience重编译汉化的方法
1. 必须有DXperience相应版本的全部源代码SourceCode.把全部源代码复制到\Program Files\Developer Express .NET vX.X\Sources目录.目 ...
- 史上最简单的个人移动APP开发入门--jQuery Mobile版跨平台APP开发
书是人类进步的阶梯. ——高尔基 习大大要求新新人类要有中国梦,鼓励大学生们一毕业就创业.那最好的创业途径是什么呢?就是APP.<构建跨平台APP-jQuery Mobile移动应用实战> ...
- Python脚本控制的WebDriver 常用操作 <一> 启动浏览器
由于本人的学习定位是基于Selenium+WebDriver+Python+FireFox+Eclipse+Pydev, 所以我的笔记也只和这方面相关. 我打算先学习基于Python脚本WebDriv ...
- static关键字的作用
static可以用来定义静态成员变量.静态函数.静态代码块. 静态成员变量的语法特点 定义方法:在成员变量前面加上static class Person{ static int i; //静态成员变量 ...
- expdp与impdp
参考http://blog.csdn.net/hello985/article/details/13295305 (一) 导出scott用户下的emp表到xx用户下 1.1 创 ...
- poj 2560 Freckles
题目连接 http://poj.org/problem?id=2560 Freckles Description In an episode of the Dick Van Dyke show, li ...
- jquery 源码学习(*)
最近在做日志统计程序,发现对方的程序是在Jquery基础上进行开发的,而公司的网站的框架是prototype.而且我也早就想了解一下Jquery源码,故决定研究Jquery源码,模拟它的方法 Jq ...