// specify the start page //then create a test and place your code there test('My first test', async t => { await t .typeText('div.FPdoLc.VlcLAe > center > input:nth-of-type(1)', 'Aditya Inapurapu') .pressKey('enter') // Use the assertion to check if the actual header text is equal to the expected one .expect(Selector('#rso > div:first-child > div.srg > div:first-child > div > div.rc > h3.r > a').innerText).eql('Aditya Inapurapu - Senior Automation / Release Engineer - Blue ...'); });
test('Gradually delete tasks and check it item', async t => { const page = new TodosPage(); await page.fillForm(t) await t .click(Selector('.alert').nth(0)) .expect(Selector('.alert').count).eql(2) .expect(Selector('.alert').nth(0).innerText).eql('task 2') .expect(Selector('.alert').nth(1).innerText).eql('task 3') .click(Selector('.alert').nth(1)) .expect(Selector('.alert').nth(0).innerText).eql('task 2') .click(Selector('.alert').nth(0)) .expect(Selector('.alert').count).eql(0) })
test('Should retrieve all main menu items', async t => { var items = await getMainMenuItems(); await t .expect(items[0].label).eql('Test') .expect(items[0].submenu[0].label).eql('Click') .expect(items[0].submenu[1].label).eql('Dialog') .expect(items[0].submenu[2].label).eql('New Menu') .expect(items[0].submenu[3].label).eql('New Menu'); });
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'); });
test('Delete Test', async t => { await t .click(Selector('td').withText('Delete').nth(-1).find('.btn.btn-dark').nth(0)) .expect(Selector('tr').nth(-1).child().nextSibling(0).innerText).notEql('Pontiac') .expect(Selector('tr').nth(-1).child().nextSibling(1).innerText).notEql('TransAm') .expect(Selector('tr').nth(-1).child().nextSibling(2).innerText).notEql('1993'); });
const passwordInputExists = passwordInput.exists; await t .expect(firstNameInputExists).ok() .typeText(firstNameInput, firstName) .expect(firstNameInput.value).eql(firstName) .expect(lastNameInputExists).ok() .typeText(lastNameInput, lastName) .expect(lastNameInput.value).eql(lastName) .expect(emailInputExists).ok() .typeText(emailInput, email) .expect(emailInput.value).eql(email) .expect(userNameInputExists).ok() .typeText(userNameInput, username) .expect(userNameInput.value).eql(username) .expect(passwordInputExists).ok() .typeText(passwordInput, password) .expect(passwordInput.value).eql(password) .expect(Selector('#success').innerText).eql("Registration request submitted successfully") });
/** * Check if the homepage content loads */ test('Welcome Page Loads', async t => { await t // Check for h1 tag .expect(Selector('#root h1').innerText).eql('Hello there') // Check for input tag .expect(Selector('#root input[type="text"]').exists).ok() // Check for submit button .expect(Selector('#root button').exists).ok() })
test('Test greeting form: with name', async t => { await t // Input name .typeText(Selector('#root input[type="text"]'), 'Atreus', { replace: true }) // Click submit button .click(Selector('#root button')) .expect(Selector('#root h1').innerText).eql('hello Atreus!') })
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'); });
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') })
/** * Test submitting the form without data */ test('Test greeting form: empty input', async t => { await t // Click submit button .click(Selector('#root button')) .expect(Selector('#root h1').innerText).eql('you didn\'t tell me who you are.') })
test('Create 1 task and check it item', async t => { await t .typeText('input', 'task 1') .click('button') .expect(Selector('.alert').innerText).eql('task 1') })