Running WebdriverIO 'spec' tests as node f

2019-06-06 18:36发布

I'm new to webdriverio. I don't understand how it's supposed to be configured and used within a node application. How do you run 'spec' tests when webdriverio is being imported? Can it be done?

// based on http://webdriver.io/guide.html
var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'firefox'
    },
    specs: './test/spec/**' // why doesn't this work, when it would work when run from the wdio cli
};

webdriverio
    .remote(options)
    .init()
    .url('http://www.google.com')
    .title(function(err, res) {
        console.log('Title was: ' + res.value);
    })
    .end();

1条回答
别忘想泡老子
2楼-- · 2019-06-06 18:59

There are two ways to use WebdriverIO. The standalone mode allows you to integrate test automation using the WebdriverIO API within arbitrary NodeJS scripts (e.g. this example). It is often used to embed WebdriverIO into a different library like Chimp.js.

The other way is the WDIO test runner (cli runner) which is better suited for sufficient e2e testing. It requires a configuration file (wdio.conf.js or whatever name you want) and to pass this file name as argument to the wdio cli command (e.g. these examples). This is the common way if you want to create an e2e test suite for your project.

查看更多
登录 后发表回答