【问题标题】:Protractor :e2e : Allure report : Issue with allure.createStep量角器:e2e:魅力报告:allure.createStep 问题
【发布时间】:2021-01-07 14:07:23
【问题描述】:

我正在使用 allure 报告,但遇到了 allure.createStep 的问题。生成报告后,附件不会添加到第一步“单击添加按钮”,实际上它会添加到下一步“候选添加按钮
这里的屏幕截图 1 转移到了下一步,屏幕截图 2 也发生了同样的情况:

下面是我正在使用的代码:->

     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');
        })();
          })

任何帮助将不胜感激:)

【问题讨论】:

    标签: javascript typescript jasmine protractor allure


    【解决方案1】:

    这是因为我没有在 attachScreenshot 函数中使用 await。

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

    非常感谢:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2023-01-07
      • 1970-01-01
      相关资源
      最近更新 更多