• <i id='hkGjD'><tr id='hkGjD'><dt id='hkGjD'><q id='hkGjD'><span id='hkGjD'><b id='hkGjD'><form id='hkGjD'><ins id='hkGjD'></ins><ul id='hkGjD'></ul><sub id='hkGjD'></sub></form><legend id='hkGjD'></legend><bdo id='hkGjD'><pre id='hkGjD'><center id='hkGjD'></center></pre></bdo></b><th id='hkGjD'></th></span></q></dt></tr></i><div id='hkGjD'><tfoot id='hkGjD'></tfoot><dl id='hkGjD'><fieldset id='hkGjD'></fieldset></dl></div>

      1. <small id='hkGjD'></small><noframes id='hkGjD'>

        • <bdo id='hkGjD'></bdo><ul id='hkGjD'></ul>
        <tfoot id='hkGjD'></tfoot>
        <legend id='hkGjD'><style id='hkGjD'><dir id='hkGjD'><q id='hkGjD'></q></dir></style></legend>

        如果我的鼻子测试失败,如何截取屏幕截图?

        时间:2023-07-05
          <bdo id='tWaZN'></bdo><ul id='tWaZN'></ul>
        • <legend id='tWaZN'><style id='tWaZN'><dir id='tWaZN'><q id='tWaZN'></q></dir></style></legend>

          <i id='tWaZN'><tr id='tWaZN'><dt id='tWaZN'><q id='tWaZN'><span id='tWaZN'><b id='tWaZN'><form id='tWaZN'><ins id='tWaZN'></ins><ul id='tWaZN'></ul><sub id='tWaZN'></sub></form><legend id='tWaZN'></legend><bdo id='tWaZN'><pre id='tWaZN'><center id='tWaZN'></center></pre></bdo></b><th id='tWaZN'></th></span></q></dt></tr></i><div id='tWaZN'><tfoot id='tWaZN'></tfoot><dl id='tWaZN'><fieldset id='tWaZN'></fieldset></dl></div>

              <tbody id='tWaZN'></tbody>
            <tfoot id='tWaZN'></tfoot>

              • <small id='tWaZN'></small><noframes id='tWaZN'>

                • 本文介绍了如果我的鼻子测试失败,如何截取屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用nosetests 运行selenium webdriver 测试.每当鼻子测试失败时,我想捕获屏幕截图.我怎样才能以最有效的方式做到这一点,无论是使用 webdriver、python 还是 nosetests 功能?

                  I am running selenium webdriver tests with nosetests. I want to capture a screenshot whenever nosetests fail. How can I do it in the most effective way, either by using webdriver, python or nosetests features?

                  推荐答案

                  我的解决方案

                  import sys, unittest
                  from datetime import datetime
                  
                  class TestCase(unittest.TestCase):
                  
                      def setUp(self):
                          some_code
                  
                      def test_case(self):
                          blah-blah-blah
                  
                      def tearDown(self):
                          if sys.exc_info()[0]:  # Returns the info of exception being handled 
                              fail_url = self.driver.current_url
                              print fail_url
                              now = datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f')
                              self.driver.get_screenshot_as_file('/path/to/file/%s.png' % now) # my tests work in parallel, so I need uniqe file names
                              fail_screenshot_url = 'http://debugtool/screenshots/%s.png' % now
                              print fail_screenshot_url
                          self.driver.quit()
                  

                  这篇关于如果我的鼻子测试失败,如何截取屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用python添加屏幕截图来诱惑报告? 下一篇:使用 Selenium 通过 PhantomJS 中的超链接下载文件

                  相关文章

                  <legend id='UzuJ5'><style id='UzuJ5'><dir id='UzuJ5'><q id='UzuJ5'></q></dir></style></legend>
                      • <bdo id='UzuJ5'></bdo><ul id='UzuJ5'></ul>

                      <small id='UzuJ5'></small><noframes id='UzuJ5'>

                    1. <tfoot id='UzuJ5'></tfoot>

                      <i id='UzuJ5'><tr id='UzuJ5'><dt id='UzuJ5'><q id='UzuJ5'><span id='UzuJ5'><b id='UzuJ5'><form id='UzuJ5'><ins id='UzuJ5'></ins><ul id='UzuJ5'></ul><sub id='UzuJ5'></sub></form><legend id='UzuJ5'></legend><bdo id='UzuJ5'><pre id='UzuJ5'><center id='UzuJ5'></center></pre></bdo></b><th id='UzuJ5'></th></span></q></dt></tr></i><div id='UzuJ5'><tfoot id='UzuJ5'></tfoot><dl id='UzuJ5'><fieldset id='UzuJ5'></fieldset></dl></div>