-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomePage.js
81 lines (72 loc) · 1.99 KB
/
HomePage.js
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
import { Selector, t } from "testcafe";
/**
* Class to declare Locators and common functions required for actions in HomePage
*/
class HomePage {
/**
* Constructor to initialise the Selectors
*/
constructor() {
this.subTitleHeader = Selector("h2").withText("Welcome to our store");
this.registerLink = Selector("a").withText("Register");
this.logInLink = Selector("a").withText("Log in");
this.shoppingCartLink = Selector("a").withText("Shopping cart");
this.logOutLink = Selector("a").withText("Log out");
this.myAccountLink = Selector("a").withText("My account");
this.currencyList = Selector("select#customerCurrency");
}
/**
* @property {Function} productSearch - Get the locator for Search box
* @returns Selector
*/
get productSearch() {
return Selector("input[id='small-searchterms']");
}
/**
* @property {Function} search - Search for the product specified
* @property {string} product - Product to be searched
* @returns void
*/
async search(product) {
await t.typeText(this.productSearch, product).wait(3000).pressKey("enter");
}
/**
* @property {Function} changeCurrency - Change the currency
* @property {string} currency - Currency type
* @returns void
*/
async changeCurrency(currency) {
await t
.click(this.currencyList)
.click(Selector("option", { text: currency }));
}
/**
* @property {Function} logInLink - Navigate to Login section
* @returns void
*/
async clickOnLogin() {
await t.click(this.logInLink);
}
/**
* @property {Function} logOutLink - Logout the current user
* @returns void
*/
async clickOnLogout() {
await t.click(this.logOutLink);
}
/**
* @property {Function} clickOnMyAccount - Navigate to My Account section
* @returns void
*/
async clickOnMyAccount() {
await t.click(this.myAccountLink);
}
/**
* @property {Function} clickOnRegisterLink - Navigate to Register section
* @returns void
*/
async clickOnRegisterLink() {
await t.click(this.registerLink);
}
}
export default new HomePage();