/
base.ts
96 lines (92 loc) · 2.45 KB
/
base.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
// This is the base Browser interface all browser
// classes should build off of, it is the bare
// methods we aim to support across tests
export class BrowserInterface {
private promise: any
private then: any
private catch: any
protected chain(nextCall: any): BrowserInterface {
if (!this.promise) {
this.promise = Promise.resolve(this)
}
this.promise = this.promise.then(nextCall)
this.then = (...args) => this.promise.then(...args)
this.catch = (...args) => this.promise.catch(...args)
return this
}
async setup(browserName: string): Promise<void> {}
async close(): Promise<void> {}
async quit(): Promise<void> {}
elementsByCss(selector: string): BrowserInterface[] {
return [this]
}
elementByCss(selector: string): BrowserInterface {
return this
}
elementById(selector: string): BrowserInterface {
return this
}
click(opts?: { modifierKey?: boolean }): BrowserInterface {
return this
}
keydown(key: string): BrowserInterface {
return this
}
keyup(key: string): BrowserInterface {
return this
}
focusPage(): BrowserInterface {
return this
}
type(text: string): BrowserInterface {
return this
}
waitForElementByCss(selector: string, timeout?: number): BrowserInterface {
return this
}
waitForCondition(snippet: string, timeout?: number): BrowserInterface {
return this
}
back(): BrowserInterface {
return this
}
forward(): BrowserInterface {
return this
}
refresh(): BrowserInterface {
return this
}
setDimensions(opts: { height: number; width: number }): BrowserInterface {
return this
}
addCookie(opts: { name: string; value: string }): BrowserInterface {
return this
}
deleteCookies(): BrowserInterface {
return this
}
async loadPage(url: string, { disableCache: boolean }): Promise<any> {}
async get(url: string): Promise<void> {}
async getValue(): Promise<any> {}
async getAttribute(name: string): Promise<any> {}
async eval(snippet: string | Function): Promise<any> {}
async evalAsync(snippet: string | Function): Promise<any> {}
async text(): Promise<string> {
return ''
}
async getComputedCss(prop: string): Promise<string> {
return ''
}
async hasElementByCssSelector(selector: string): Promise<boolean> {
return false
}
async log(): Promise<any[]> {
return []
}
async websocketFrames(): Promise<any[]> {
return []
}
async url(): Promise<string> {
return ''
}
}