/** * Get the amount of swag items on the page * * @returns {Promise<number>} */ getAmount() { return this.swagItems.count; }
/** * Get the cart amount * * @return {Promise<string>} */ async getCartAmount() { await t.wait(500); return this.cart.innerText; }
test.disablePageReloads('Browse items inside listing', async t => { debugger const itemsCount = db.articles.length await t.expect(await page.fields.id.count).eql(itemsCount) await t.expect(await page.fields.title.count).eql(itemsCount) await t.expect(await page.fields.published_at.count).eql(itemsCount) })
/** * Check if the error message is displayed * * @returns {Promise<boolean>} */ isErrorMessageDisplayed() { return this.errorMessage.visible; }
/** * Get the swag item header based on text or a number * * @param {string|number} needle * * @returns {Selector} */ getSwagItemHeader(needle){ return this.getSwagItem(needle).find('.inventory_item_name'); }
test.disablePageReloads('Create article through form', async t => { debugger const typeOptions = { paste: true } await t.typeText(page.inputs.title, title, typeOptions) await t.typeText(page.inputs.teaser, teaser, typeOptions) await t.typeText(page.inputs.body, body, typeOptions) await t.typeText(page.inputs.published_at, publishedAt) await t.click(page.form.find('button[type=submit]')) await t.expect(page.title.innerText).eql(`Article #${db.articles.length + 1}`) })
/** * 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 first shopping list', async (t) => { await loginFirstUser(t) await waitSelector(t, 'ShoppingLists', Selector('.example-form-control')) await t.typeText( await Selector('.example-form-control'), 'First Shopping List' ) await t.click(await Selector('button').withText('Add Shopping List')) await refreshAndWait(t, () => Selector('.shopping-list').count, 2) })
// 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('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('create second shopping list', async (t) => { await loginFirstUser(t) await waitSelector(t, 'ShoppingLists', Selector('.example-form-control')) await t.typeText( await Selector('.example-form-control'), 'Second Shopping List' ) await t.click(await Selector('button').withText('Add Shopping List')) await refreshAndWait(t, () => Selector('.shopping-list').count, 3) })
/** * Get the swag item add button based on text or a number * * @param {string|number} needle * * @returns {Selector} */ getSwagItemAddButton(needle){ return this.getSwagItem(needle).find('.btn_primary.btn_inventory'); }