• <bdo id='TgpHE'></bdo><ul id='TgpHE'></ul>
        <tfoot id='TgpHE'></tfoot>

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

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

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

        如何使用python添加屏幕截图来诱惑报告?

        How to add a screenshot to allure report with python?(如何使用python添加屏幕截图来诱惑报告?)
          <legend id='Zu6SW'><style id='Zu6SW'><dir id='Zu6SW'><q id='Zu6SW'></q></dir></style></legend>

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

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

              <tfoot id='Zu6SW'></tfoot>
              • <i id='Zu6SW'><tr id='Zu6SW'><dt id='Zu6SW'><q id='Zu6SW'><span id='Zu6SW'><b id='Zu6SW'><form id='Zu6SW'><ins id='Zu6SW'></ins><ul id='Zu6SW'></ul><sub id='Zu6SW'></sub></form><legend id='Zu6SW'></legend><bdo id='Zu6SW'><pre id='Zu6SW'><center id='Zu6SW'></center></pre></bdo></b><th id='Zu6SW'></th></span></q></dt></tr></i><div id='Zu6SW'><tfoot id='Zu6SW'></tfoot><dl id='Zu6SW'><fieldset id='Zu6SW'></fieldset></dl></div>
                    <tbody id='Zu6SW'></tbody>
                  本文介绍了如何使用python添加屏幕截图来诱惑报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这个代码:

                  # coding: utf-8
                  from selenium import webdriver
                  import pytest
                  import allure
                  
                  
                  @pytest.yield_fixture(scope='session')
                  def driver():
                      _driver = webdriver.PhantomJS()
                      yield _driver
                      _driver.quit()
                  
                  
                  def test_ya(driver):
                      with allure.step('open ya.ru and take screenshot'):
                          driver.get('http://ya.ru/')            
                          allure.attach('screenshot', driver.get_screenshot_as_png(), type='png')
                  

                  我尝试截取屏幕截图并将其保存到诱惑报告中,执行后我有:

                  and I try to take a screenshot and save it to allure report, after execution I have:

                  >       with self._attachfile("%s-attachment.%s" % (uuid.uuid4(), attach_type.extension)) as f:
                              if isinstance(body, text_type):
                  E           AttributeError: 'str' object has no attribute 'extension'
                  

                  我该如何解决这个问题?

                  How can I fix this?

                  推荐答案

                  For allure 2

                  For allure 2

                  from allure_commons.types import AttachmentType
                  
                  allure.attach(driver.get_screenshot_as_png(), name="Screenshot", attachment_type=AttachmentType.PNG)
                  

                  这篇关于如何使用python添加屏幕截图来诱惑报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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% 就足够了)

                      <tbody id='IK5Fp'></tbody>
                      1. <small id='IK5Fp'></small><noframes id='IK5Fp'>

                      2. <tfoot id='IK5Fp'></tfoot><legend id='IK5Fp'><style id='IK5Fp'><dir id='IK5Fp'><q id='IK5Fp'></q></dir></style></legend>
                          <bdo id='IK5Fp'></bdo><ul id='IK5Fp'></ul>

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