Skip to content

Instantly share code, notes, and snippets.

@aurelienlair
Created May 9, 2021 20:41
Show Gist options
  • Save aurelienlair/a2efc97c3b9ee72161e005d648f1b31b to your computer and use it in GitHub Desktop.
Save aurelienlair/a2efc97c3b9ee72161e005d648f1b31b to your computer and use it in GitHub Desktop.
Venue page object
class Venue {
urls = {
"Louvre museum": "https://www.musement.com/uk/paris/louvre-museum-v/",
"Eiffel tower": "https://www.musement.com/uk/paris/eiffel-tower-v/",
};
async open(venueName, deviceType) {
opts["capabilities"] = capabilities[deviceType.toLowerCase()];
this.mobileBrowser = await wdio.remote(opts);
await this.mobileBrowser.setTimeout({ pageLoad: 10000 });
await this.mobileBrowser.url(this.urls[venueName]);
}
async closeCovidMeasuresLink() {
const elem = await this.mobileBrowser.$('//button[contains(text(), "×")]');
await elem.waitForDisplayed({ timeout: 10000 });
await elem.click();
}
async acceptCookies() {
const cookieBanner = await this.mobileBrowser.$("msm-cookie-banner");
const acceptCookiesButton = await cookieBanner.shadow$(
'[data-test="cookie-banner__accept-cookies"]'
);
await acceptCookiesButton.waitForDisplayed({ timeout: 10000 });
await acceptCookiesButton.click();
}
async clickOn(buttonTitle) {
const viewMoreButton = await this.mobileBrowser.$(
`//span[contains(text(), "${buttonTitle}")]`
);
await viewMoreButton.waitForDisplayed({ timeout: 10000 });
await viewMoreButton.click();
}
async lookForUniqueExperiences() {
const findDuplicates = (arr) =>
arr.filter((item, index) => arr.indexOf(item) !== index);
let activitiesTitle = [];
const activitiesElements = await this.mobileBrowser.$$(
"[data-test=attractionPage__catalogCards-box] [data-test=ActivityCard__title] a"
);
const promises = activitiesElements.map(async (element) => {
return await element.getText();
});
activitiesTitle = await Promise.all(promises);
console.log(activitiesTitle);
const duplicates = findDuplicates(activitiesTitle);
assert.equal(
duplicates.length,
0,
`Found ${duplicates.length} duplicated experiences\n${duplicates}`
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment