[英]node.js: calling a function in webdriverio using mocha
我正在編寫許多測試用例。 所有這些都有一個共同的部分(登錄用戶並執行其他操作)。
因此,我希望沒有一個函數在每個測試中都編寫該函數來調用它。
我嘗試使用.then和.call,但是會引發錯誤:
.setValue('#signin_email', LogInEmail)
^
SyntaxError: Unexpected token .
這件事是怎么做的?
你是這個意思嗎 http://webdriver.io/guide/usage/customcommands.html
browser.addCommand("LogInEmail", function () {
return browser
.setValue('#signin_email', 'emailaddress')
.setValue('#password', 'password');
});
// to invoke
browser.LogInEmail()
如果您想在每次mocha測試之前運行您的公用部分,則將其放在這樣的beforeEach()函數中。
describe('some test', function() {
beforeEach(function() {
// your common part here
});
it('it should do something, function() {
...
});
...
it('it should do something else', function() {
...
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.