简体   繁体   English

Protractor:e2e:魅力报告:allure.createStep 问题

[英]Protractor :e2e : Allure report : Issue with allure.createStep

I am using allure report and facing a issue with allure.createStep.我正在使用 allure 报告并面临 allure.createStep 的问题。 When the report is generated then the attachment is not getting added to the first step ' Click on Add Button ' infact it is getting added to the next step ' Candidate Add Button '生成报告后,附件不会被添加到第一步“单击添加按钮”中,实际上它会被添加到下一步“候选添加按钮”中
Here screenshot 1 shifted to next step and same happened for screenshot 2:这里屏幕截图 1 转移到了下一步,屏幕截图 2 也发生了同样的情况:

在此处输入图像描述

Below is the code I am using:->以下是我正在使用的代码:->

     async function attachScreenshot(filename: string) {
          browser.takeScreenshot().then(function (png) {
            allure.createAttachment(filename, function () {
              return Buffer.from(png, 'base64')
            }, 'image/png')();
          })
        }
    
    
        fit('Create Candidate', async () => {
            await browser.refresh();
    // First Step
             await allure.createStep("Click on Add Button ", async () => {
            await browser.wait(until.elementToBeClickable(SpadesPageObj.add), 20000, 'Add Button');
            await SpadesPageObj.add.click();
             await attachScreenshot('1');
            })();
            
    // Second Step
    
    await allure.createStep("Candidate Add Button", async () => {
              await browser.wait(until.elementToBeClickable(SpadesPageObj.candidate), 20000, 'Add Candidate Button');
              await SpadesPageObj.candidate.click();
              await attachScreenshot('2');
            })();
            // await browser.wait(until.elementToBeClickable(SpadesPageObj.candidate), 20000, 'Add Candidate Button');
            // await SpadesPageObj.candidate.click();
            // await allure.createAttachment('Candidate Add Button ', new Buffer(png, 'base64'));
            //});
//Third step
            await allure.createStep("Resume upload", async () => {
              var path = require('path');
              var remote = require('../../node_modules/selenium-webdriver/remote');
              browser.setFileDetector(new remote.FileDetector());
              var fileToUpload = './resume.docx';
              var absolutePath = path.resolve(process.cwd() + fileToUpload);
              await element(by.css('input[type="file"]')).sendKeys(absolutePath);
              await attachScreenshot('3');
        })();
          })

Any help will be appreciated:)任何帮助将不胜感激:)

It was happening because I have not used await in the attachScreenshot function.发生这种情况是因为我没有在 attachScreenshot function 中使用 await。

async function attachScreenshot(filename: string) {
     await browser.takeScreenshot().then(function (png) {
        allure.createAttachment(filename, function () {
          return Buffer.from(png, 'base64')
        }, 'image/png')();
      })
    }

Thank you very much:)非常感谢:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM