I created a simple 'page objects' example. I get the following error messages when executing the test case:
- AssertionError: expected false to be truthy
- Unhandled promise rejection
I used the following commands to execute my test:
npm run test:firefox
or
npm run test:firefox -e
I hope someone can tell me what I'm doing wrong.
// page object (navbar-page.js)
import { Selector } from 'testcafe'
class NavbarPage {
constructor() {
this.searchBox = Selector("#searchTerm")
}
async search(text) {
await t.typeText(this.searchBox, text, { paste: true, replace: true }).pressKey('enter')
}
}
export default NavbarPage
// Test case (search.test.js)
import { Selector } from 'testcafe'
import NavbarPage from '../page-objects/navbar-page';
const pageObject = new NavbarPage()
fixture`Search test`
.page`http://zero.webappsecurity.com/`
test('Search box should work', async t => {
const result_title = Selector('h2').withText("Search Results:")
pageObject.search('banking')
await t.expect(result_title.exists).ok()
})
My expectation:
- The test case shall insert the term "banking" within the search input field.
- Test case shall press enter to search for the given term.
- Result page shall display the results.