selenium2_python自动化测试实战课件.ppt
《selenium2_python自动化测试实战课件.ppt》由会员分享,可在线阅读,更多相关《selenium2_python自动化测试实战课件.ppt(52页珍藏版)》请在三一办公上搜索。
1、,LOGO,selenium2 python,自动化测试实战,-虫师http:/,http:/itest.info,LOGOselenium2 python自动化测试实战,http:/itest.info,http:/itest.info,http:/itest.info,前言:,为什么要做自动化测试?A、节省手工测试的人才和成本B、有助于提升测试团队的技术力量C、能够生成直观的图形化报表D、我不知道,领导要求做的,http:/itest.info前言:为什么要做自动化测试,http:/itest.info,前言:,分层的自动化测试,http:/itest.info前言:分层的自动化测试,ht
2、tp:/itest.info,前言:,什么样的产品适合做自动化测试?功能成熟(需求变动较小)产品更新维护周期长项目进度不太大比较频繁的回归测试软件开发比较规范,具有可测试性可以脚本具有可复用性,http:/itest.info前言:什么样的产品适合做自,http:/itest.info,本课程学习重点:,selenium 技术: 元素定位的几种方法 WebDriver API ,selenium IDE,selenium gridpython 技术: 函数、类、方法;读写文件,unitest单元测试框架,HTMLTestRunner.py,发邮件模块,多线程技术等。,http:/itest.i
3、nfo本课程学习重点:,http:/itest.info,selenium,selenium 的特点:开源,免费多浏览器支持:firefox、chrome、IE多平台支持:linux 、windows、MAC多语言支持:java、python、ruby、php、C#、对web页面有良好的支持简单(API 简单)、灵活(用开发语言驱动)支持分布式测试用例执行,http:/itest.infoseleniumselen,http:/itest.info,selenium 家谱,selenium 1.0 :,selenium 2.0 = selenium 1.0 + WebDriver,http:/
4、itest.infoselenium 家谱se,http:/itest.info,http:/itest.info,http:/itest.info,环境搭建:,window 安装:第一步、安装python第二步、安装setuptoolsC:setuptools-1.3python setup.py install第三步、安装pipC:pip-1.4.1 python setup.py install 第四步、安装seleniumC:Python27Scripts pip install -U selenium环境变量:,变量名:PATH变量值:;C:Python27,http:/itest.
5、info环境搭建:window 安,http:/itest.info,环境搭建:,简易安装(ActivePython): ActivePython 包含了一个完整的 Python 内核,并附加了一些 Python 的 Windows扩展第一步、下载安装ActivePython第二步、安装seleniumC:Python27Scripts pip install -U selenium,http:/itest.info环境搭建:简易安装(Act,http:/itest.info,环境搭建:,linux安装(ubuntu):第一步、安装:setuptoolsrootfnngj-H24X:# apt
6、-get install python-setuptools第二步、安装piprootfnngj-H24X:./pip-1.4.1# python setup.py install第三步、安装seleniumrootfnngj-H24X:./pip-1.4.1# pip install -U selenium,http:/itest.info环境搭建:linux安装(,http:/itest.info,第一个自动化脚本:,百度搜索:,http:/itest.info第一个自动化脚本:百度搜索,http:/itest.info,http:/itest.info,http:/itest.info,
7、元素的定位:,WebDriver 提供的八种定位方法:find_element_by_id()find_element_by_name()find_element_by_class_name()find_element_by_tag_name()find_element_by_link_text()find_element_by_partial_link_text()find_element_by_xpath()find_element_by_css_selector(),http:/itest.info元素的定位:WebDriv,http:/itest.info,元素的定位:,idnamec
8、lass nametag name :百度搜索框前端代码(通过firebug查看)find_element_by_id(kw1)find_element_by_name(wd)find_element_by_class_name(s_ipt)find_element_by_tag_name(input)注:页面上的元素tag name 相同的几率很高,http:/itest.info元素的定位:idname,http:/itest.info,元素的定位:,linkpartial link :百度首页文字链接:新 闻贴 吧知 道find_element_by_link_text(u新 闻)fin
9、d_element_by_partial_link_text(新)find_element_by_link_text(u贴 吧).注:中文字符串加u 是将中文转换成unicode,防止编码问题。,http:/itest.info元素的定位:linkpa,http:/itest.info,元素的定位:,xpath :find_element_by_xpath(/*id=kw1)find_element_by_xpath(/inputid=kw1)find_element_by_xpath(/inputname=wd)find_element_by_xpath(/inputclass=s_ipt)
10、find_element_by_xpath(/spanclass=bg s_iptwr/input)find_element_by_xpath(/formid=form1/span/input).find_element_by_xpath(/html/body/div/div4/div2/div/form/span/input),http:/itest.info元素的定位:xpath :,http:/itest.info,元素的定位:,CSS 常见语法:,http:/itest.info元素的定位:CSS 常见语,http:/itest.info,元素的定位:,CSS :定位find_elem
11、ent_by_css_selector(from)定位find_element_by_css_selector(.subdiv)find_element_by_css_selector(from+div)定位find_element_by_css_selector(#recordlist)find_element_by_css_selector(ul#recordlist)find_element_by_css_selector(divul)定位Headingfind_element_by_css_selector(divul)find_element_by_css_selector(div.
12、subdiv ul p), Heading,http:/itest.info元素的定位:CSS :/,http:/itest.info,http:/itest.info,http:/itest.info,WebDriver API:,浏览器最大化:maximize_window()设置浏览器宽、高:set_window_size(480, 800)控制浏览器后退,前进:back()forward(),http:/itest.infoWebDriver API,http:/itest.info,WebDriver API:,WebElement接口常用方法:clear 清除元素的内容send_k
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- selenium2_python 自动化 测试 实战 课件
![提示](https://www.31ppt.com/images/bang_tan.gif)
链接地址:https://www.31ppt.com/p-1288092.html