• <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添加屏幕截图来诱惑报告?

        时间:2023-07-05
          <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添加屏幕截图来诱惑报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 Selenium Webdriver 下载时命名文件 下一篇:如果我的鼻子测试失败,如何截取屏幕截图?

                  相关文章

                    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>

                    3. <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>