python+selenium自动化环境配置及使用实例

一、搭建环境相关地址以及相关模块下载地址

1、#各个浏览器驱动下载地址:

https://www.cnblogs.com/nancyzhu/p/8589764.html 

2、#sublime+python+selenium自动化配置教程:

http://python.tedu.cn/know/289803.html 

3、#html测试报告:

https://github.com/defnngj/HTMLTestRunner         http://www.testpub.cn/t/213 

4、#page objects插件下载地址 pip install page_objects:

https://github.com/eeaston/page-objects 

5、邮件模板下载地址pip3  install yagmail:

https://github.com/kootenpv/yagmail

二、使用实例

1、模块级别的fixture:

2、类级别的fixture:

3、鼠标悬停事件:

     js使用方法:

     js = '' var q = document.getElementsByClassName(\''类名\'')[0];q.style.display=\''block\'' ; ''

     driver.execute_script(js)

4、规范:元素定位与动作分离:

5、测试执行discover匹配文件:

6、测试报告:

fp = unittest.defaultTestLoader.discover('./','testcase*.py')

runner = HTMLTestRunner.HTMLTestRunner(

                    stream=fp,

                    title=u'测试报告',

                    description=u'版本:V1.0,报告人:xxx'

)

runner.run(fp)

7、发送邮件:

8、测试套件、测试执行:

猜你喜欢

转载自www.cnblogs.com/schblog/p/10859902.html
今日推荐