page.js
unknown
javascript
a year ago
3.0 kB
2
Indexable
Never
module.exports = { // Inputs fromField: '#from', toField: '#to', phoneNumberField: '#phone', codeField: '#code', cardNumberField: '#number', messageToDriver: '#comment', cardCode: '#code.card-input', // Buttons callATaxiButton: 'button=Call a taxi', phoneNumberButton: '//div[starts-with(text(), "Phone number")]', nextButton: 'button=Next', confirmButton: 'button=Confirm', supportivePlanButton: 'div=Supportive', paymentMethodButton: '//div[@class="pp-text"]', addCard: '//div[contains(text(), "Add card")]', linkButton: 'button=Link', paymentMethod: 'div.pp-button.filled > div.pp-value > div.pp-value-text', addBlanket: 'div=Blanket and handkerchiefs', iceCreamButton: 'div=+', closeButton: 'div.payment-picker.open > div.modal > div.section.active > button', orderButton: 'div.smart-button-wrapper > button > span.smart-button-main', // Misc iceCreamNumber: '.counter .counter-value', carSearch: 'div.order.shown > div.order-body > div.order-header > div > div.order-header-title', driverInfo: 'div.order.shown > div.order-body > div.order-subbody > div.order-buttons > div:nth-child(1)', // Modals phoneNumberModal: '.modal', // Functions fillAddresses: async function(from, to) { const fromField = await $(this.fromField); await fromField.setValue(from); const toField = await $(this.toField); await toField.setValue(to); const callATaxiButton = await $(this.callATaxiButton); await callATaxiButton.waitForDisplayed(); await callATaxiButton.click(); }, fillPhoneNumber: async function(phoneNumber) { const phoneNumberButton = await $(this.phoneNumberButton); await phoneNumberButton.waitForDisplayed(); await phoneNumberButton.click(); const phoneNumberModal = await $(this.phoneNumberModal); await phoneNumberModal.waitForDisplayed() const phoneNumberField = await $(this.phoneNumberField); await phoneNumberField.waitForDisplayed(); await phoneNumberField.setValue(phoneNumber); }, submitPhoneNumber: async function(phoneNumber) { await this.fillPhoneNumber(phoneNumber); // we are starting interception of request from the moment of method call await browser.setupInterceptor(); await $(this.nextButton).click(); // we should wait for response // eslint-disable-next-line wdio/no-pause await browser.pause(2000); const codeField = await $(this.codeField); // collect all responses const requests = await browser.getRequests(); // use first response await expect(requests.length).toBe(1) const code = await requests[0].response.body.code await codeField.setValue(code) await $(this.confirmButton).click() }, };