一、摘要

本博文将介绍Python和Selenium进行自动化测试时,借助html-testRunner 生成自动化测试报告

安装命令:pip install html-testRunner

二、测试代码

# encoding = utf-8
'''
@Time : 2018/8/14 20:41
@Author : davieyang
@File : test_AjaxElement.py
@Software: PyCharm
'''
import traceback from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import unittest
import time
import HtmlTestRunner class TestAjaxElement(unittest.TestCase): def setUp(self):
self.driver = webdriver.Chrome() def test_AjaxDivOptionByKeys(self):
"""simulate keyboadr keydonw and enter and by circulating"""
url = 'http://www.sogou.com'
self.driver.get(url)
searchBox = self.driver.find_element_by_id('query')
searchBox.send_keys("selenium")
time.sleep(3)
for i in range(3):
searchBox.send_keys(Keys.DOWN)
time.sleep(3)
searchBox.send_keys(Keys.ENTER)
time.sleep(3) def test_AjaxDivOptionByWords(self):
"""using xpath to fuzzy match"""
url = 'http://www.sogou.com'
self.driver.get(url)
try:
searchBox = self.driver.find_element_by_id('query')
searchBox.send_keys(u'光荣之路')
time.sleep(3)
suggetion_option = self.driver.find_element_by_xpath("//ul/li[contains(.,'@#')]")
suggetion_option.click()
time.sleep(3)
except NoSuchElementException as e:
print(traceback.print_exc()) def test_error(self):
""" This test should be marked as error one. """
raise ValueError def test_fail(self):
""" This test should fail. """
self.assertEqual(1, 2) @unittest.skip("This is a skipped test.")
def test_AjaxDivOptionByIndex(self):
"""using xpath to locate"""
url = 'http://www.sogou.com'
self.driver.get(url)
try:
searchBox = self.driver.find_element_by_id('query')
searchBox.send_keys(u'光荣之路')
time.sleep(3)
suggetion_option = self.driver.find_element_by_xpath("//*[@id='vl']/div[1]/ul/li[3]")
suggetion_option.click()
time.sleep(3)
except NoSuchElementException as e:
print(traceback.print_exc()) def tearDown(self):
self.driver.quit() if __name__ == '__main__':
unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='D:\\Programs\\Python\\PythonUnittest\\Reports\\'))

三、报告样式

Python&Selenium借助html-testRunner生成自动化测试报告的更多相关文章

  1. Python+Selenium----使用HTMLTestRunner.py生成自动化测试报告2(使用PyCharm )

    1.说明 在我前一篇文件(Python+Selenium----使用HTMLTestRunner.py生成自动化测试报告1(使用IDLE ))中简单的写明了,如何生产测试报告,但是使用IDLE很麻烦, ...

  2. Python+Selenium----使用HTMLTestRunner.py生成自动化测试报告1(使用IDLE)

    1.说明 自动化测试报告是一个很重要的测试数据,网上看了一下,使用HTMLTestRunner.py生成自动化测试报告使用的比较多,但是呢,小白刚刚入手,不太懂,看了很多博客,终于生成了一个测试报告, ...

  3. Python&Selenium&pytest借助allure生成自动化测试报告

    一.摘要 本篇博文将介绍Python和Selenium进行自动化测试时,如何借助allure生成自动化测试报告 二.环境配置 首先python环境中安装pytest和pytest_allure_ada ...

  4. Python&Selenium借助HTMLTestRunner生成自动化测试报告

    一.摘要 本篇博文介绍Python和Selenium进行自动化测试时,借助著名的HTMLTestRunner生成自动化测试报告 HTMLTestRunner.py百度很多,版本也很多,自行搜索下载放到 ...

  5. python +selenium 自带case +生成报告的模板

    https://github.com/huahuijay/python-selenium2这个就是 python +selenium的 里面还自带case 然后也有生成报告的模板 我的: https: ...

  6. python+selenium 输出2种样式的测试报告

    第一种: 1.通过 HTMLTestRunner 模块输出报告 2.下载连接 http://tungwaiyip.info/software/HTMLTestRunner.html 3.将下载好的文件 ...

  7. 【Python Selenium】简单数据生成脚本

    最近因工作需要,写了一个简单的自动化脚本,纯属学习,顺便学习下selenium模块. 废话不多说,直接上代码!! 这里一位大神重写了元素定位.send_keys等方法,咱们直接进行调用. 适用Pyth ...

  8. windiows下搭建python+selenium+unittest+Chrome的Web自动化环境

    一.selenium.unittest概念 Selenium 是用于测试 Web 应用程序用户界面 (UI) 的常用框架.它是一款用于运行端到端功能测试的超强工具.您可以使用多个编程语言编写测试,并且 ...

  9. mvn + testng + allure 生成自动化测试报告

    最近学了个新东西,使用java的testng测试框架做自动化测试.并且声称自动化报告. (1)创建maven工程 File-New-Other (2)创建testng类 当前import org.te ...

随机推荐

  1. 分布式消息通信之RabbitMQ Tutorials

    目录 官网 1 Hello World! 1.1 生产者demo producer 1.2 消费者demo consumer 1.3 查看queue队列中的信息 页面查看,可看到有4条消息 命令查看 ...

  2. 从Odds:比值比推导出Logtic分类的算法

    在从概率模型推导出逻辑回归算法模型的博文中,我试着从李宏毅老师的课程中讲到的概率模型去推导逻辑分类的算法模型.有幸看到另外一篇博文01 分类算法 - Logistic回归 - Logit函数,我了解到 ...

  3. spring的控制器如何跳转到指定的视图

    1.控制器代码 2.跳转代码 return "greeting"; 引号内为跳转的页面,默认不需要加html

  4. [转帖]nginx 禁止ip访问以及禁止post方法的简单方法

    nginx禁止IP访问站点的设置方法 http://www.512873.com/archives/471.html http://www.512873.com/archives/312.html c ...

  5. SQL SERVER 字符串函数 REPLACE()

    定义: REPLACE()返回用另一个字符串值替换原字符串中出现的所有指定字符串值之后的字符串. 语法: REPLACE ( string_expression , string_pattern , ...

  6. 什么是阿里云SCDN

    简介 SCDN(Secure Content Delivery Network),即拥有安全防护能力的CDN服务,提供稳定加速的同时,智能预判攻击行为,通过智能的调度系统将DDoS攻击请求切换至高防I ...

  7. fiddler笔记:TimeLine时间轴选项卡

    1.TimeLine选项卡介绍 TimeLine选项卡支持使用"瀑布"模型查看1~250个选中的Session.主要用于帮助性能分析和理解请求之间的关联.选项卡的主体内容是数据流视 ...

  8. 关于RESTful API

    添几篇文章: 一.What Is REST? 二.RESTful API最佳实践 三.MS Azure——API Design 这些文章里面也推荐了一些关联文章,微软那篇最详细,非常值得一读.

  9. 旋转动画(RotateTransform)

    Silverlight的基础动画包括偏移.旋转.缩放.倾斜和翻转动画,这些基础动画毫无疑问是在Silverlight中使用得最多的动画效果,其使用也是非常简单的.相信看过上一篇<偏移动画(Tra ...

  10. 自定义策略-简单实践 <一>

    1.建立   netcore  mvc 项目. 2.startup.cs 中添加服务 services.AddAuthorization(option=> { var requirements ...