如何在webdriverIO的屏幕快照名称中获取测试套件/测试用例名称?

时间:2019-09-15 09:50:22

标签: javascript selenium protractor mocha webdriver-io

describe("Test_suite_name",()=>{
  it("Test_case_name",()=>{
      //some code
   })
 })

预期:如何获取在describe块下的"Test suite name""Test case name"

输出应为:Test_suite_name.pngTest_case_name.png

2 个答案:

答案 0 :(得分:1)

为什么不使用wdio.conf.js文件中的可用钩子?

beforeTest: function (test, context) {
    console.log('--- Running test: ' + test.title);
},

答案 1 :(得分:0)

尝试以下选项

  let mySpec = it("tests a feature", function(){
    this.specName = mySpec.getFullName();  // "tests a feature"
    browser.goto("https://google.com");
    expect(browser.title).toContain("Google");
  });

OR

jasmine.getEnv().addReporter({
    specStarted: function(result) {
        console.log(result.fullName);
    }
});

希望它对您有帮助