test('Create 3 task and check it items', async t => { await t .typeText('input', 'task 1') .click('button') .typeText('input', 'task 2') .click('button') .typeText('input', 'task 3') .click('button') .expect(Selector('.alert').count).eql(3) .expect(Selector('.alert').nth(0).innerText).eql('task 1') .expect(Selector('.alert').nth(1).innerText).eql('task 2') .expect(Selector('.alert').nth(2).innerText).eql('task 3') })
/** * Sign in * * @param {object} userDetails * @param {string} userDetails.username * @param {string} userDetails.password * * @return {Promise<void>} */ async signIn(userDetails) { const {password, username} = userDetails; if (username !== '') { await t.typeText(this.username, username); } if (password !== '') { await t.typeText(this.password, password); } await t.click(this.loginButton); }
test('Add Test', async t => { await t .click(Selector('button').withText('Add')) .selectText(Selector('[name="make"].form-control')) .typeText(Selector('[name="make"].form-control'), 'Pontiac') .selectText(Selector('[name="model"].form-control')) .typeText(Selector('[name="model"].form-control'), 'TransAm') .selectText(Selector('[name="year"].form-control')) .typeText(Selector('[name="year"].form-control'), '1993') .click(Selector('button').withText('Save')) .expect(Selector('tr').nth(-1).child().nextSibling(0).innerText).eql('Pontiac') .expect(Selector('tr').nth(-1).child().nextSibling(1).innerText).eql('TransAm') .expect(Selector('tr').nth(-1).child().nextSibling(2).innerText).eql('1993'); });
/** * Submit personal info * * @param {object} personalInfo * @param {string} personalInfo.firstName * @param {string} personalInfo.lastName * @param {string} personalInfo.zip * * @returns {Promise<void>} */ async submitPersonalInfo(personalInfo) { const {firstName, lastName, zip} = personalInfo; if (firstName !== '') { await t.typeText(this.firstName, firstName); } if (lastName !== '') { await t.typeText(this.lastName, lastName); } if (zip !== '') { await t.typeText(this.postalCode, zip); } await t.click(this.continueCheckoutButton); }
await t .expect(firstNameInputExists).ok() .typeText(firstNameInput, firstName) .expect(firstNameInput.value).eql(firstName) .typeText(lastNameInput, lastName) .expect(lastNameInput.value).eql(lastName) .typeText(emailInput, email) .expect(emailInput.value).eql(email) .typeText(userNameInput, username) .expect(userNameInput.value).eql(username) .typeText(passwordInput, password) .expect(passwordInput.value).eql(password)
test('Edit Test', async t => { await t .click(Selector('td').withText('Edit').find('.btn.btn-primary').nth(0)) .selectText(Selector('[name="make"].form-control')) .typeText(Selector('[name="make"].form-control'), 'DMC') .selectText(Selector('[name="model"].form-control')) .typeText(Selector('[name="model"].form-control'), 'DeLorean') .selectText(Selector('[name="year"].form-control')) .typeText(Selector('[name="year"].form-control'), '1981') .click(Selector('button').withText('Save')) .expect(Selector('tbody > tr > td').nextSibling(0).innerText).eql('DMC') .expect(Selector('tbody > tr > td').nextSibling(1).innerText).eql('DeLorean') .expect(Selector('tbody > tr > td').nextSibling(2).innerText).eql('1981'); });