-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathhome-page-model.ts
86 lines (64 loc) · 2.34 KB
/
home-page-model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { type BrowserContext, type Locator, type Page } from '@playwright/test';
import CommonPage from './common-page-model';
class HomePage extends CommonPage {
readonly operationalStudiesLink: Locator;
readonly cartoLink: Locator;
readonly editorLink: Locator;
readonly rollingStockEditorLink: Locator;
readonly STDCMLink: Locator;
readonly linksTitle: Locator;
readonly backHomeLogo: Locator;
readonly dropDown: Locator;
readonly userSettings: Locator;
readonly OSRDLanguage: Locator;
constructor(page: Page) {
super(page);
this.operationalStudiesLink = page.locator('a[href="/operational-studies/projects"]');
this.STDCMLink = page.locator('a[href="/stdcm"]');
this.editorLink = page.locator('a[href="/editor"]');
this.rollingStockEditorLink = page.locator('a[href="/rolling-stock-editor"]');
this.cartoLink = page.locator('a[href="/map"]');
this.linksTitle = page.getByTestId('page-title');
this.backHomeLogo = page.getByTestId('osrd-logo');
this.dropDown = page.getByTestId('dropdown-sncf');
this.userSettings = page.getByTestId('user-settings-btn');
this.OSRDLanguage = page.getByTestId('language-info');
}
// Navigate to the Home page
async goToHomePage() {
await this.page.goto('/');
await this.removeViteOverlay();
}
// Click on the logo to navigate back to the home page
async backToHomePage() {
await this.backHomeLogo.click();
await this.page.waitForLoadState();
}
async goToOperationalStudiesPage() {
await this.operationalStudiesLink.click();
}
async goToCartoPage() {
await this.cartoLink.click();
}
async goToEditorPage() {
await this.editorLink.click();
}
async goToRollingStockEditorPage() {
await this.rollingStockEditorLink.click();
}
async goToSTDCMPage(context: BrowserContext) {
// Wait for the new page to be created
const [stdcmPage] = await Promise.all([context.waitForEvent('page'), this.STDCMLink.click()]);
// Ensure the new page is fully loaded before proceeding
await stdcmPage.waitForLoadState();
return stdcmPage;
}
// Get OSRD selected language
async getOSRDLanguage(): Promise<string> {
await this.dropDown.click();
const selectedLanguage = await this.OSRDLanguage.innerText();
await this.dropDown.click();
return selectedLanguage;
}
}
export default HomePage;