我想在用户登录主页后断言我在“主页”上。我创建了一个函数“onPage”来返回 URL 的内容。
这是代码:
function onPage (secondPage, URL) {
if (secondPage === 'Home Page') {
return await
testController.expect(URL.textContent).contains('URL-of-the-Home-Page');
}
}
Then(THEN.THE_HOME_PAGE_IS_OPENED, async (secondPage) => {
await testController.expect(onPage(secondPage, URL)).eql(true);
}
Run Code Online (Sandbox Code Playgroud)
这是我的 BDD 场景:
Scenario Outline: User is logged in the
Given the <namePage> is opened
And the user populate <username>
And the user populate <password>
When the user clicks on Login button
Then he is on <secondPage>
Examples:
| namePage | username | password | secondPage |
| "Login Page" | …Run Code Online (Sandbox Code Playgroud)