【问题标题】:can't attach screen shots to mocha allure reporter for protractor tests无法将屏幕截图附加到 mocha allure 记者进行量角器测试
【发布时间】:2020-04-21 11:41:16
【问题描述】:

我正在尝试将屏幕截图附加到诱惑报告中。我没有收到任何错误,但报告没有显示任何屏幕截图

"mocha-allure-reporter": "1.4.0",

这里是 testbase.ts

import { login_Page } from '../pageObjects/LL1_loginPage'
import { browser } from 'protractor'
declare const allure: any;
before(function () {
  login_Page.login()
  browser.sleep(3000)
  login_Page.pageLoadConfirmation()
})
afterEach(function () {
  allure.createStep('initial', () => {
    browser.takeScreenshot().then(function (png) { allure.createAttachment('title', new Buffer(png, 'base64')); })
    console.log("successful")
  });
})

mocha 在配置文件中设置

mochaOpts: {
  slow: 90000,
    timeout: 180000,
      reporter: 'mocha-allure-reporter'
},
framework: 'mocha',

【问题讨论】:

    标签: typescript protractor mocha.js ui-automation allure


    【解决方案1】:

    通过以下代码实现

     afterEach(async function(){
        const png = await browser.takeScreenshot()
        allure.createAttachment('screenshot',new Buffer(png,'base64'),'image/png')
      })
    

    【讨论】:

      【解决方案2】:

      这会对你有所帮助。

      afterEach(async function () { const png = await browser.takeScreenshot(); allure.createAttachment('Screenshot', new Buffer(png, 'base64'), 'image/png'); })

      【讨论】:

        【解决方案3】:

        这对我有用,没有 Deprecated Buffer 问题:

        afterEach(async function() {
        const png = await browser.takeScreenshot();
        allure.createAttachment("Screenshot", Buffer.from(png, "base64"), "image/png");
        });
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-09-04
          • 1970-01-01
          • 1970-01-01
          • 2021-04-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多