2019-07-17 14:56:48 -04:00
|
|
|
module.exports.constants = {
|
|
|
|
nextStepXpath: '//button[span[contains(text(), "Next Step")]]',
|
|
|
|
generalErrorMessageXpath: '//span[@class="help-block validation-message"]/span[contains(text(),' +
|
|
|
|
'"This field is required")]',
|
|
|
|
loremIpsumTextLong: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur viverra' +
|
|
|
|
'nec mauris efficitur tincidunt. Vestibulum ut diam odio. Cum sociis natoque penatibus et magnis dis' +
|
|
|
|
'parturient montes, nascetur ridiculus mus. Morbi non enim dolor. Vestibulum at enim vestibulum, ullamcorper' +
|
|
|
|
'Duis eget quam pharetra, ultricies est eu, pharetra nisi. In tempor cursus nisi, non sagittis quam gravida.'
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.fillUsernameSlide = function (driver, seleniumWebdriver) {
|
2023-10-24 14:22:28 -04:00
|
|
|
const passwordInput = driver.findElement(seleniumWebdriver.By.name('user.password'));
|
|
|
|
const usernameInput = driver.findElement(seleniumWebdriver.By.name('user.username'));
|
|
|
|
const usernamePromise = usernameInput.sendKeys('clipspringer');
|
|
|
|
const passwordPromise = passwordInput.sendKeys('educators');
|
|
|
|
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(module.exports.constants.nextStepXpath));
|
|
|
|
return Promise.all([usernamePromise, passwordPromise]).then(() => { // eslint-disable-line no-undef
|
|
|
|
nextStepButton.click().then(() => {
|
2019-07-17 14:56:48 -04:00
|
|
|
driver.wait(seleniumWebdriver.until
|
|
|
|
.elementLocated(seleniumWebdriver.By.className('demographics-step')));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.fillDemographicsSlide = function (driver, seleniumWebdriver) {
|
2023-10-24 14:22:28 -04:00
|
|
|
const clickMaleInput = driver.findElement(seleniumWebdriver.By.xpath('//input[@value="male"' +
|
2019-07-17 14:56:48 -04:00
|
|
|
'and @type="radio"]')).click();
|
2023-10-24 14:22:28 -04:00
|
|
|
const selectCountry = driver.findElement(seleniumWebdriver.By.xpath('//select[@name="user.country"]' +
|
2019-07-17 14:56:48 -04:00
|
|
|
'/option[@value="us"]')).click();
|
2023-10-24 14:22:28 -04:00
|
|
|
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(module.exports.constants.nextStepXpath));
|
|
|
|
return Promise.all([clickMaleInput, selectCountry]).then(() => { // eslint-disable-line no-undef
|
|
|
|
nextStepButton.click().then(() => {
|
2019-07-17 14:56:48 -04:00
|
|
|
driver.wait(seleniumWebdriver.until
|
|
|
|
.elementLocated(seleniumWebdriver.By.className('name-step')));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.fillNameSlide = function (driver, seleniumWebdriver) {
|
2023-10-24 14:22:28 -04:00
|
|
|
const firstNamePromise = driver.findElement(seleniumWebdriver.By.name('user.name.first')).sendKeys('first');
|
|
|
|
const lastNamePromise = driver.findElement(seleniumWebdriver.By.name('user.name.last')).sendKeys('surname');
|
|
|
|
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(module.exports.constants.nextStepXpath));
|
|
|
|
return Promise.all([firstNamePromise, lastNamePromise]).then(() => { // eslint-disable-line no-undef
|
|
|
|
nextStepButton.click().then(() => {
|
2019-07-17 14:56:48 -04:00
|
|
|
driver.wait(seleniumWebdriver.until
|
|
|
|
.elementLocated(seleniumWebdriver.By.className('phone-step')));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.fillPhoneSlide = function (driver, seleniumWebdriver) {
|
2023-10-24 14:22:28 -04:00
|
|
|
const phoneInput = driver.findElement(seleniumWebdriver.By.xpath('//input[@type="tel"]'));
|
|
|
|
const consentCheckbox = driver.findElement(seleniumWebdriver.By.name('phoneConsent'));
|
|
|
|
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(module.exports.constants.nextStepXpath));
|
|
|
|
const phoneNumberPromise = phoneInput.sendKeys('6172535960');
|
|
|
|
const consentPromise = consentCheckbox.click();
|
|
|
|
return Promise.all([phoneNumberPromise, consentPromise]).then(() => { // eslint-disable-line no-undef
|
|
|
|
nextStepButton.click().then(() => {
|
2019-07-17 14:56:48 -04:00
|
|
|
driver.wait(seleniumWebdriver.until
|
|
|
|
.elementLocated(seleniumWebdriver.By.className('organization-step')));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.fillOrganizationSlide = function (driver, seleniumWebdriver) {
|
2023-10-24 14:22:28 -04:00
|
|
|
const organizationInput = driver.findElement(seleniumWebdriver.By.name('organization.name'));
|
|
|
|
const titleInput = driver.findElement(seleniumWebdriver.By.name('organization.title'));
|
|
|
|
const typeCheckbox = driver.findElement(seleniumWebdriver.By.xpath('//input[@type="checkbox" and @value="3"]'));
|
|
|
|
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(module.exports.constants.nextStepXpath));
|
|
|
|
const organizationPromise = organizationInput.sendKeys('MIT Media Lab');
|
|
|
|
const titlePromise = titleInput.sendKeys('Software Developer');
|
|
|
|
const typePromise = typeCheckbox.click();
|
2019-07-17 14:56:48 -04:00
|
|
|
return Promise.all([organizationPromise, titlePromise, typePromise]) // eslint-disable-line no-undef
|
2023-10-24 14:22:28 -04:00
|
|
|
.then(() => {
|
|
|
|
nextStepButton.click().then(() => {
|
2019-07-17 14:56:48 -04:00
|
|
|
driver.wait(seleniumWebdriver.until
|
|
|
|
.elementLocated(seleniumWebdriver.By.className('address-step')));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.fillAddressSlide = function (driver, seleniumWebdriver) {
|
2023-10-24 14:22:28 -04:00
|
|
|
const addressInput = driver.findElement(seleniumWebdriver.By.name('address.line1'));
|
|
|
|
const cityInput = driver.findElement(seleniumWebdriver.By.name('address.city'));
|
|
|
|
const zipCodeInput = driver.findElement(seleniumWebdriver.By.name('address.zip'));
|
|
|
|
const nextStepButton = driver.findElement(seleniumWebdriver.By.xpath(module.exports.constants.nextStepXpath));
|
|
|
|
const addressPromise = addressInput.sendKeys('77 Massachusetts Avenue, E14/E15');
|
|
|
|
const cityPromise = cityInput.sendKeys('Cambridge');
|
|
|
|
const statePromise = driver.findElement(seleniumWebdriver.By.xpath('//select[@name="address.state"]' +
|
2019-07-17 14:56:48 -04:00
|
|
|
'/option[@value="us-ma"]')).click();
|
2023-10-24 14:22:28 -04:00
|
|
|
const zipPromise = zipCodeInput.sendKeys('02139');
|
2019-07-17 14:56:48 -04:00
|
|
|
return Promise.all([addressPromise, cityPromise, statePromise, zipPromise]) // eslint-disable-line no-undef
|
2023-10-24 14:22:28 -04:00
|
|
|
.then(() => {
|
|
|
|
nextStepButton.click().then(() => {
|
2019-07-17 14:56:48 -04:00
|
|
|
driver.wait(seleniumWebdriver.until
|
|
|
|
.elementLocated(seleniumWebdriver.By.className('usescratch-step')));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|