如何使用Python + Webdriver + nose& amp;显示捕获屏幕截图到报告中的xUnit

时间:2017-03-28 11:23:09

标签: python-2.7 selenium-webdriver nose xunit

如何显示使用 Python + Webdriver + nose&>将屏幕截图捕获到报告中xunit

Python脚本:

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

class GoogleTest(unittest.TestCase):

    def test_google(self):


        self.driver = webdriver.Firefox()
        self.driver.get("http://www.google.com")
        assert False, "Desperately failing to capture screenshot"

    def tearDown(self):

        self.driver.save_screenshot("/tmp/screenshot.png")
        print ("/tmp/screenshot.png")
        self.driver.quit()
        unittest.TestCase.tearDown(self)

请找到report.xml

<?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="1" errors="0" failures="1" skip="0"><testcase classname="sample.GoogleTest" name="test_google" time="4.921"><failure type="exceptions.AssertionError" message="Desperatly failing to capture screenshot"><![CDATA[Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 331, in run
    testMethod()
  File "/home/anuj/workspace/py_sel/sample.py", line 17, in test_google
    assert False, "Desperatly failing to capture screenshot"
AssertionError: Desperatly failing to capture screenshot
]]></failure></testcase></testsuite>

0 个答案:

没有答案