-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjeorgisPage.ts
171 lines (147 loc) · 5.87 KB
/
jeorgisPage.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import { By } from "selenium-webdriver";
import { BasePage } from "./basePage";
const fs= require('fs');
export class LibraryClass extends BasePage {
//! Locators
askBtn: By = By.id('lcs_slide_out_button-22303')
catalogSB: By = By.xpath('(//input[@id="searchTitle"])[3]')
resultCata: By = By.xpath('//a[text()="Sword of truth"]')
webSiteBtn: By = By.xpath('(//span[text()="WEBSITE"])[3]')
websiteSB: By = By.xpath('(//input[@id="searchWebsite"])[3]')
resultWeb: By = By.xpath('(//b[text()="Rosetta Stone"])[1]')
homeBtn: By = By.xpath('(//a[text()="The County Library"])[1]')
eventsBtn: By = By.xpath('//a[text()="Events"]')
bigPlay: By = By.xpath('//a[text()="The Big Play"]')
winReading: By = By.xpath('//a[text()="Winter Reading"]')
learnBtn: By = By.xpath('//a[text()="Learn"]')
health: By = By.xpath('//a[text()="Health"]')
homework: By = By.xpath('//a[text()="Homework Help"]')
whatWeBtn: By = By.xpath('//a[text()="What We Have"]')
comingSoon: By = By.xpath('//a[text()="Coming Soon"]')
newMusic: By = By.xpath('//a[text()="New Music"]')
weRecommendBtn: By = By.xpath('//a[text()="We Recommend"]')
bookClub: By = By.xpath('//a[text()="Book Clubs"]')
forTeens: By = By.xpath('//a[text()="For Teens"]')
locationsBtn: By = By.xpath('//span[text()="Locations"]')
daybreak: By = By.xpath('//h5[text()="DAYBREAK"]')
address: By = By.xpath('//a[text()="11358 Grandville Ave, South Jordan, UT 84009"]')
redDot: By = By.xpath('//div[text()="Daybreak"]')
getDir: By = By.xpath('//a[text()="Get Directions"]')
access: By = By.css('.mon-logo-image')
font: By = By.xpath('//button[@class="column arrow-left"]')
//! Constructor
constructor() {
super({url:'https://www.slcolibrary.org/'})
};
//! Methods
async getCataResults() {
return this.getText(this.resultCata)
};
async getWebResults() {
return this.getText(this.resultWeb)
};
async searchC(searchThing: string) {
return this.setInput(this.catalogSB, `${searchThing}\n`);
};
async searchW(searchThing: string) {
return this.setInput(this.websiteSB, `${searchThing}\n`);
};
async cataTabs() {
let myTabs = await this.driver.getAllWindowHandles();
await this.driver.switchTo().window(myTabs[1]);
await this.driver.sleep(1500);
let cataText = await this.getCataResults();
expect(cataText).toContain('Sword of truth');
fs.writeFile(`${__dirname}/catalog.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
await this.driver.close();
await this.driver.switchTo().window(myTabs[0]);
};
async numTabs() {
let myTabs = await this.driver.getAllWindowHandles();
await this.driver.switchTo().window(myTabs[1]);
await this.driver.sleep(1500);
fs.writeFile(`${__dirname}/numPar.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
await this.driver.close();
await this.driver.switchTo().window(myTabs[0]);
};
async symTabs() {
let myTabs = await this.driver.getAllWindowHandles();
await this.driver.switchTo().window(myTabs[1]);
await this.driver.sleep(1500);
fs.writeFile(`${__dirname}/symPar.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
await this.driver.close();
await this.driver.switchTo().window(myTabs[0]);
};
async letTabs() {
let myTabs = await this.driver.getAllWindowHandles();
await this.driver.switchTo().window(myTabs[1]);
await this.driver.sleep(1500);
fs.writeFile(`${__dirname}/letPar.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
await this.driver.close();
await this.driver.switchTo().window(myTabs[0]);
};
async locTabs() {
let myTabs = await this.driver.getAllWindowHandles();
await this.driver.switchTo().window(myTabs[1]);
await this.driver.sleep(1500);
fs.writeFile(`${__dirname}/loc.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
await this.driver.close();
await this.driver.switchTo().window(myTabs[0]);
};
async dirTabs() {
let myTabs = await this.driver.getAllWindowHandles();
await this.driver.switchTo().window(myTabs[1]);
await this.driver.sleep(1500);
fs.writeFile(`${__dirname}/dir.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
await this.driver.close();
await this.driver.switchTo().window(myTabs[0]);
};
async canHover() {
const hoverAction = this.driver.actions()
const ctaElement = await this.getElement(this.redDot)
await this.actionWiggle(hoverAction, ctaElement, 100)
await hoverAction.perform() // Actions don't actually happen until perform is called
};
async scroll() {
const frame = await this.driver.findElement(By.xpath('//a[text()="Winter Reading"]'));
await this.driver.actions()
.move({ origin: frame })
.perform();
fs.writeFile(`${__dirname}/bigText.png`,
await this.driver.takeScreenshot(), "base64",
(e) =>{
if (e) console.log;
else console.log("This worked!");
});
};
};