当前位置:   article > 正文

Python自动化测试系列[v1.0.0][html-testRunner测试报告]_pip install html-testrunner==1.0.3

pip install html-testrunner==1.0.3

安装

pip install html-testRunner
  • 1

测试代码

# 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\\'))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78

测试报告

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/437995
推荐阅读
相关标签
  

闽ICP备14008679号