如何在黄瓜步骤定义中实现httpAuth



testCafe中有一种处理httpAuth的方法,http://devexpress.github.io/testcafe/documentation/test-api/authentication/http-authentication.html,我正在尝试测试一个网站,首先我必须通过httpAuth。上述功能适用于夹具。我应该如何处理黄瓜步骤定义中的httpAuth?一个非常值得赞赏的例子。

我的stepdef类似于

给定("页面已加载",异步函数(({wait testController.anavigateTo('http://example.com'(.httpAuth({用户名:'logmein',密码:'test123'})});

我得到

TypeError:testController.anavigateTo(…(.httpAuth不是函数

fixture.httpAuth方法中的test.httpAuth用于指定单个测试或固定装置要使用的凭据,因此这些方法应在testfixture的上下文中使用,而不应在testController的上下文中。不能在测试体中使用httpAuth。请参阅文档中的示例(https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/authentication.html#http-身份验证(:

fixture `My fixture`
.page `http://example.com`
.httpAuth({
username: 'username',
password: 'Pa$$word',
// Optional parameters, can be required for the NTLM authentication.
domain:      'CORP-DOMAIN',
workstation: 'machine-win10'
});
test('Test1', async t => {});          // Logs in as username
test                                   // Logs in as differentUserName
.httpAuth({
username: 'differentUserName',
password: 'differentPa$$word'
})
('Test2', async t => {});

最新更新