Running WebdriverIO 'spec' tests as node file

别说谁变了你拦得住时间么 提交于 2019-12-23 02:37:30

问题


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:


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.



来源:https://stackoverflow.com/questions/33311721/running-webdriverio-spec-tests-as-node-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!