无法将屏幕截图附加到 mocha allure reporter 以进行量角器测试
can't attach screen shots to mocha allure reporter for protractor tests
我正在尝试将屏幕截图附加到魅力报告中。我没有收到任何错误,但报告没有显示任何屏幕截图
"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',
通过以下代码实现
afterEach(async function(){
const png = await browser.takeScreenshot()
allure.createAttachment('screenshot',new Buffer(png,'base64'),'image/png')
})
这对你有帮助。
afterEach(async function () {
const png = await browser.takeScreenshot();
allure.createAttachment('Screenshot', new Buffer(png, 'base64'), 'image/png');
})
这对我有用,没有已弃用的缓冲区问题:
afterEach(async function() {
const png = await browser.takeScreenshot();
allure.createAttachment("Screenshot", Buffer.from(png, "base64"), "image/png");
});
我正在尝试将屏幕截图附加到魅力报告中。我没有收到任何错误,但报告没有显示任何屏幕截图
"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',
通过以下代码实现
afterEach(async function(){
const png = await browser.takeScreenshot()
allure.createAttachment('screenshot',new Buffer(png,'base64'),'image/png')
})
这对你有帮助。
afterEach(async function () {
const png = await browser.takeScreenshot();
allure.createAttachment('Screenshot', new Buffer(png, 'base64'), 'image/png');
})
这对我有用,没有已弃用的缓冲区问题:
afterEach(async function() {
const png = await browser.takeScreenshot();
allure.createAttachment("Screenshot", Buffer.from(png, "base64"), "image/png");
});