admin管理员组文章数量:1191316
How to extend WebdriverIO V9 capability to add some additional parameters.I have tried the following method, but it's not met my requirement.
wdio.conf.ts
interface CustomParams {
testCaseId?: number;
testRunId?: number;
}
export const config: WebdriverIO.Config & { customParams: CustomParams } = {
runner: "local",
tsConfigPath: "./tsconfig.json",
specs: ["./test/specs/**/*.ts"],
exclude: [],
maxInstances: 10,
capabilities: [
{
browserName: "chrome"
}
],
customParams: {
testCaseId: 1,
testRunId: 1
},
after: function (result, capabilities, specs) {
console.log("capabilities: ------", capabilities);
}
};
custom-reporter.ts
import WDIOReporter, { RunnerStats } from "@wdio/reporter";
import type { Reporters } from "@wdio/types";
import type TestStats from "@wdio/reporter/build/stats/test";
interface CustomRunnerStats extends RunnerStats {
config: RunnerStats["config"] & { customParams: { testCaseId?: number; testRunId?: number } };
}
let customParams: { testCaseId?: number | undefined; testRunId?: number | undefined };
export default class CustomReporter extends WDIOReporter {
constructor(options: Partial<Reporters.Options>) {
options = Object.assign(options, { stdout: true });
super(options);
}
async onRunnerStart(runnerStats: CustomRunnerStats) {
customParams = runnerStats.config.customParams;
console.log(":::::::::::::::::::: onRunnerStart ~ customParams:", customParams);
}
async onTestPass(test: TestStats) {
this.write(`Congratulations! Your test "${test.title}" passed
本文标签:
webdriver ioHow to extend and use WebdriverIO V9 capabilitiesStack Overflow
版权声明:本文标题:webdriver io - How to extend and use WebdriverIO V9 capabilities - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1738447187a2087280.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论