• <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>

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

        How do I capture a screenshot if my nosetests fail?(如果我的鼻子测试失败,如何截取屏幕截图?)
          <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()
                  

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

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)
                    <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'>

                        • <tfoot id='UzuJ5'></tfoot>

                              <tbody id='UzuJ5'></tbody>
                            <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>