save changes
This commit is contained in:
@ -49,6 +49,21 @@ export async function clickSeeAll(driver: WebDriver): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSeeAllUrl(driver: WebDriver): Promise<string> {
|
||||
const xpath = `//h3[normalize-space(.)='Things to do']/ancestor::div[1]//a[starts-with(@href, '/Attractions')]`;
|
||||
|
||||
try {
|
||||
const anchor = await driver.wait(until.elementLocated(By.xpath(xpath)), 5000);
|
||||
const url = await anchor.getAttribute('href');
|
||||
console.log('Found Attractions URL:', url);
|
||||
return url;
|
||||
} catch (err) {
|
||||
console.warn('Could not find the Attractions link:', err);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
export async function gotoHome(driver: WebDriver): Promise<boolean> {
|
||||
try {
|
||||
// Click on the Tripadvisor logo before searching for the city
|
||||
@ -82,6 +97,22 @@ export async function clickSeeAllAttractions(driver: WebDriver): Promise<boolean
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSeeAllAttractionsUrl(driver: WebDriver): Promise<string | null> {
|
||||
const xpath = `//h2[starts-with(normalize-space(.), 'Top Attractions in')]/parent::*[1]//a[starts-with(@href, '/Attractions') and .//span[normalize-space(.)='See all']]`;
|
||||
|
||||
try {
|
||||
const anchorElement = await driver.wait(until.elementLocated(By.xpath(xpath)), 5000);
|
||||
|
||||
await driver.wait(until.elementIsVisible(anchorElement), 5000);
|
||||
|
||||
const href = await anchorElement.getAttribute('href');
|
||||
return href;
|
||||
} catch (error) {
|
||||
console.warn('Element not found or href not retrievable.', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function clickMuseumsLink(driver: WebDriver): Promise<boolean> {
|
||||
const xpath = `//a[.//*[normalize-space(.)='Museums']]`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user