Code Monkey home page Code Monkey logo

Comments (1)

kafkaliang avatar kafkaliang commented on June 30, 2024

通过在日志中打印截图路径,获取截图转base64,添加到报告中

    if getattr(test, 'images', []):
            tmp = ""
            hidde_status = ''
            for i, img in enumerate(test.images):
                if i == 0:
                    tmp += """<img src="data:image/jpg;base64,{}" style="display: block;" class="img"/>\n""".format(img)
                else:
                    tmp += """<img src="data:image/jpg;base64,{}" style="display: none;" class="img"/>\n""".format(img)
            screenshots_html = CustomTemplate.IMG_TMPL.format(images=tmp)
        else:
            screenshots_html = """"""
            unum = str(uo).rfind('screenshot_path:')
            if (uo or ue) and unum != -1:
                hidde_status = ''
                left_key = str(uo).rfind('screenshot_path:')
                right_key = str(uo).rfind('png')
                image_path = str(uo)[left_key+16:right_key + 3].replace(' ', '')
                # 打开并读取图片文件
                with open(image_path, 'rb') as img_file:
                    img_data = img_file.read()

                # 使用base64库将图片数据编码
                encoded_img = base64.b64encode(img_data).decode('utf-8')

                tmp += """<img src="data:image/jpg;base64,{}" class="img"/>\n""".format(encoded_img)
                screenshots_html = CustomTemplate.IMG_TMPL.format(images=tmp)

from xtestrunner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.