diff --git a/test/contents/autofillTest.js b/test/contents/autofillTest.js index ccdb098311a..4c9f18ae255 100644 --- a/test/contents/autofillTest.js +++ b/test/contents/autofillTest.js @@ -9,19 +9,38 @@ const saveAddressButton = '[data-test-id="saveAddressButton"]' const addCreditCardButton = '[data-test-id="addCreditCardButton"]' const saveCreditCardButton = '[data-test-id="saveCreditCardButton"]' const name = 'Brave Lion' +const nameInput = '[data-test-id="nameOnAddress"]' const organization = 'Brave' +const organizationInput = '[data-test-id="organization"]' const streetAddress = '1161 Mission Street, #401' +const streetInput = '[data-test-id="streetAddress"]' const city = 'San Francisco' +const cityInput = '[data-test-id="city"]' const state = 'CA' +const stateInput = '[data-test-id="state"]' const postalCode = '94103-1550' +const postalCodeInput = '[data-test-id="postalCode"]' const country = 'US' +const countryInput = '[data-test-id="country"]' const phone = '0987654321' +const phoneInput = '[data-test-id="phone"]' const email = 'press@brave.com' +const emailInput = '[data-test-id="email"]' const cardName = 'Test Card' +const cardNameInput = '[data-test-id="creditCardName"]' const cardNumber = '1234567890' +const cardNumberInput = '[data-test-id="creditCardNumber"]' const expMonth = 9 const expYear = new Date().getFullYear() + 2 +// auto fill form +const formFullNameInput = '[name="04fullname"]' +const formPhoneInput = '[name="23cellphon"]' +const formEmailInput = '[name="24emailadr"]' +const formCardNameInput = '[name="41ccnumber"]' +const formCreditMonthInput = '[name="42ccexp_mm"]' +const formCreditYearInput = '[name="43ccexp_yy"]' + describe('Autofill', function () { function * setup (client) { yield client @@ -44,24 +63,24 @@ describe('Autofill', function () { .click(addAddressButton) .windowByUrl(Brave.browserWindowUrl) .waitForVisible(autofillAddressPanel) - .waitForElementFocus('[data-test-id="nameOnAddress"]') - .keys(name) - .click('[data-test-id="organization"]') - .keys(organization) - .click('[data-test-id="streetAddress"]') - .keys(streetAddress) - .click('[data-test-id="city"]') - .keys(city) - .click('[data-test-id="state"]') - .keys(state) - .click('[data-test-id="postalCode"]') - .keys(postalCode) - .click('[data-test-id="country"]') - .keys(country) - .click('[data-test-id="phone"]') - .keys(phone) - .click('[data-test-id="email"]') - .keys(email) + .waitForElementFocus(nameInput) + .typeText(nameInput, name) + .click(organizationInput) + .typeText(organizationInput, organization) + .click(streetInput) + .typeText(streetInput, streetAddress) + .click(cityInput) + .typeText(cityInput, city) + .click(stateInput) + .typeText(stateInput, state) + .click(postalCodeInput) + .typeText(postalCodeInput, postalCode) + .click(countryInput) + .typeText(countryInput, country) + .click(phoneInput) + .typeText(phoneInput, phone) + .click(emailInput) + .typeText(emailInput, email) .click(saveAddressButton) .waitUntil(function () { return this.getAppState().then((val) => { @@ -75,29 +94,29 @@ describe('Autofill', function () { yield this.app.client .waitForVisible('[data-test-id="autofillPage"]') .waitForTextValue('[data-test-id="addressName"]', name) - .waitForTextValue('[data-test-id="organization"]', organization) - .waitForTextValue('[data-test-id="streetAddress"]', streetAddress) - .waitForTextValue('[data-test-id="city"]', city) - .waitForTextValue('[data-test-id="state"]', state) - .waitForTextValue('[data-test-id="postalCode"]', postalCode) - .waitForTextValue('[data-test-id="country"]', country) - .waitForTextValue('[data-test-id="phone"]', phone) - .waitForTextValue('[data-test-id="email"]', email) + .waitForTextValue(organizationInput, organization) + .waitForTextValue(streetInput, streetAddress) + .waitForTextValue(cityInput, city) + .waitForTextValue(stateInput, state) + .waitForTextValue(postalCodeInput, postalCode) + .waitForTextValue(countryInput, country) + .waitForTextValue(phoneInput, phone) + .waitForTextValue(emailInput, email) }) it('autofills the address', function * () { yield this.app.client .tabByIndex(0) .loadUrl(this.formfill) .waitForVisible('