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

    • <bdo id='VJZBX'></bdo><ul id='VJZBX'></ul>
    1. <legend id='VJZBX'><style id='VJZBX'><dir id='VJZBX'><q id='VJZBX'></q></dir></style></legend>

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

      1. <tfoot id='VJZBX'></tfoot>
      2. Python 中 Selenium Webdriver 测试失败时的自动截图

        Automatic screenshots when test fail by Selenium Webdriver in Python(Python 中 Selenium Webdriver 测试失败时的自动截图)
          <bdo id='kuA9g'></bdo><ul id='kuA9g'></ul>

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

            <tbody id='kuA9g'></tbody>

          <legend id='kuA9g'><style id='kuA9g'><dir id='kuA9g'><q id='kuA9g'></q></dir></style></legend>

            <i id='kuA9g'><tr id='kuA9g'><dt id='kuA9g'><q id='kuA9g'><span id='kuA9g'><b id='kuA9g'><form id='kuA9g'><ins id='kuA9g'></ins><ul id='kuA9g'></ul><sub id='kuA9g'></sub></form><legend id='kuA9g'></legend><bdo id='kuA9g'><pre id='kuA9g'><center id='kuA9g'></center></pre></bdo></b><th id='kuA9g'></th></span></q></dt></tr></i><div id='kuA9g'><tfoot id='kuA9g'></tfoot><dl id='kuA9g'><fieldset id='kuA9g'></fieldset></dl></div>
            <tfoot id='kuA9g'></tfoot>
                • 本文介绍了Python 中 Selenium Webdriver 测试失败时的自动截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果我的 webdriver 测试失败(任何异常或断言错误),我想自动捕获屏幕截图.我正在使用 Python unittest 和 Selenium Webdriver.有没有人可以解决这个问题?

                  I want to automatic capturing screenshots if my webdriver tests failed (any exception or assertion error). I am using Python unittest and Selenium Webdriver. Does anyone have any solution to this problem?

                  推荐答案

                  在 Firefox 中做一些 webdriver 的东西...保存任何异常的截图到一个过时的图像文件:

                  do some webdriver stuff in Firefox... save screenshot on any exception to a dated image file:

                  from datetime import datetime
                  from selenium import webdriver
                  
                  browser = webdriver.Firefox()
                  
                  try:
                      # do some webdriver stuff here
                  except Exception as e:
                      print e
                      now = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
                      browser.get_screenshot_as_file('screenshot-%s.png' % now)
                  

                  这篇关于Python 中 Selenium Webdriver 测试失败时的自动截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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% 就足够了)
                  <i id='xeD5Q'><tr id='xeD5Q'><dt id='xeD5Q'><q id='xeD5Q'><span id='xeD5Q'><b id='xeD5Q'><form id='xeD5Q'><ins id='xeD5Q'></ins><ul id='xeD5Q'></ul><sub id='xeD5Q'></sub></form><legend id='xeD5Q'></legend><bdo id='xeD5Q'><pre id='xeD5Q'><center id='xeD5Q'></center></pre></bdo></b><th id='xeD5Q'></th></span></q></dt></tr></i><div id='xeD5Q'><tfoot id='xeD5Q'></tfoot><dl id='xeD5Q'><fieldset id='xeD5Q'></fieldset></dl></div>
                • <small id='xeD5Q'></small><noframes id='xeD5Q'>

                    <bdo id='xeD5Q'></bdo><ul id='xeD5Q'></ul>

                        • <legend id='xeD5Q'><style id='xeD5Q'><dir id='xeD5Q'><q id='xeD5Q'></q></dir></style></legend>
                            <tbody id='xeD5Q'></tbody>
                            <tfoot id='xeD5Q'></tfoot>