History
• Developed in 2004byJasonHuggins as aJavaScriptlibraryusedtoautomatehis manualtestingroutines
• Selenium Core isbornwhosefunctionalityunderlies theSelenium RC(RemoteControl)andSelenium IDE
tools
• The Limitationofhaving aJavaScriptbasedautomationengine andbrowsersecurityrestrictedSelenium to
specific functionality
• In 2007SimonStewartdeveloped WebDriver.
• In 2009,Selenium andWebDrivermerged technologiesandintellectual intelligence toprovidethebest
possibletestautomationframework
TestCafestructure
fixture `My fixture`
.page `http://example.com`
.beforeEach( async t => {
/* test initialization code */
})
.afterEach( async t => {
/* test finalization code */
});
test
.before( async t => {
/* test initialization code */
})
('MyTest', async t => { /* ... */ })
.after( async t => {
/* test finalization code */
});
test.skip('MyTest2', async t => { /* ... */ })
test.only('MyTest3', async t => { /* ... */ })
TestController
• A testcontrollerobject t exposes the test API's methods. That is whyit is passed to each function that is
expected to contain server-side test code.
• Use the test controller to call test actions, handle browser dialogs, use the wait function or execute
assertions.
test('Wait Example', async t => {
await t.wait(1000)
}
Assertions
• To construct assertions use TestController expectmethod
await t.expect('actual').eql('expected', 'message', 'options');
await t.click(btn).expect(btn.textContext).contains('loading');
Consolemessages
Accessing Console Messages
When a JavaScript error occurs on a tested web page, TestCafe stops
test execution and posts an error message and a stack trace to a report
t.getBrowserConsoleMessages()
Things to consider
• No large support community yet
• Runs in single tab ( no multiple tabs )
• Not as many plugins available compared with selenium
• No suitable for native/hybrid app testing