1 | import { By, WebElement } from 'selenium-webdriver';
|
2 | import {Definition, NightwatchAPI, Awaitable, Element, ELEMENT_KEY, ScopedSelector} from './index';
|
3 |
|
4 | export interface NightwatchExpectResult {
|
5 | value: null;
|
6 | returned: 1;
|
7 | }
|
8 |
|
9 | export interface ExpectLanguageChains<T> {
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | to: T;
|
15 | be: T;
|
16 | been: T;
|
17 | is: T;
|
18 | that: T;
|
19 | which: T;
|
20 | and: T;
|
21 | has: T;
|
22 | have: T;
|
23 | with: T;
|
24 | at: T;
|
25 | does: T;
|
26 | of: T;
|
27 | same: T;
|
28 |
|
29 | |
30 |
|
31 |
|
32 | not: T;
|
33 |
|
34 | |
35 |
|
36 |
|
37 | deep: T;
|
38 | }
|
39 |
|
40 | export interface ExpectEqual<T> {
|
41 | (value: any): Awaitable<T, NightwatchExpectResult>;
|
42 | }
|
43 |
|
44 | export interface ExpectInclude<T> {
|
45 | (value: string): Awaitable<T, NightwatchExpectResult>;
|
46 | }
|
47 |
|
48 | export interface ExpectMatch<T> {
|
49 | (regexp: RegExp): Awaitable<T, NightwatchExpectResult>;
|
50 | }
|
51 |
|
52 | export interface ExpectStartWith<T> {
|
53 | (value: string): Awaitable<T, NightwatchExpectResult>;
|
54 | }
|
55 |
|
56 | export interface ExpectEndWith<T> {
|
57 | (value: string): Awaitable<T, NightwatchExpectResult>;
|
58 | }
|
59 |
|
60 | export interface ExpectAssertions<T> extends ExpectLanguageChains<T> {
|
61 | equal: ExpectEqual<T>;
|
62 | equals: ExpectEqual<T>;
|
63 | eq: ExpectEqual<T>;
|
64 |
|
65 | include: ExpectInclude<T>;
|
66 | includes: ExpectInclude<T>;
|
67 | contain: ExpectInclude<T>;
|
68 | contains: ExpectInclude<T>;
|
69 |
|
70 | match: ExpectMatch<T>;
|
71 | matches: ExpectMatch<T>;
|
72 |
|
73 | startWith: ExpectStartWith<T>;
|
74 | startsWith: ExpectStartWith<T>;
|
75 |
|
76 | endWith: ExpectEndWith<T>;
|
77 | endsWith: ExpectEndWith<T>;
|
78 |
|
79 | before: (ms: number) => Awaitable<T, NightwatchExpectResult>;
|
80 | after: (ms: number) => Awaitable<T, NightwatchExpectResult>;
|
81 |
|
82 |
|
83 | toEqual: (value: any) => NightwatchAPI;
|
84 | toBe: (value: any) => NightwatchAPI;
|
85 | toContain: (value: string) => NightwatchAPI;
|
86 | toMatch: (regexp: RegExp) => NightwatchAPI;
|
87 | toEndWith: (value: string) => NightwatchAPI;
|
88 | }
|
89 |
|
90 | export interface ExpectCookie extends ExpectAssertions<ExpectCookie> {}
|
91 |
|
92 | export interface ExpectElement extends ExpectAssertions<ExpectElement> {
|
93 | |
94 |
|
95 |
|
96 | a(type: string, message?: string): Awaitable<this, NightwatchExpectResult>;
|
97 |
|
98 | |
99 |
|
100 |
|
101 | an(type: string, message?: string): Awaitable<this, NightwatchExpectResult>;
|
102 |
|
103 | |
104 |
|
105 |
|
106 | active: Awaitable<this, NightwatchExpectResult>;
|
107 |
|
108 | |
109 |
|
110 |
|
111 | attribute(
|
112 | attribute: string,
|
113 | message?: string
|
114 | ): Awaitable<this, NightwatchExpectResult>;
|
115 |
|
116 | |
117 |
|
118 |
|
119 | css(
|
120 | property: string,
|
121 | message?: string
|
122 | ): Awaitable<this, NightwatchExpectResult>;
|
123 |
|
124 | |
125 |
|
126 |
|
127 | enabled: Awaitable<this, NightwatchExpectResult>;
|
128 |
|
129 | |
130 |
|
131 |
|
132 | present: Awaitable<this, NightwatchExpectResult>;
|
133 |
|
134 | |
135 |
|
136 |
|
137 |
|
138 | property(
|
139 | name: string,
|
140 | message?: string
|
141 | ): Awaitable<this, NightwatchExpectResult>;
|
142 |
|
143 | |
144 |
|
145 |
|
146 | selected: Awaitable<this, NightwatchExpectResult>;
|
147 |
|
148 | |
149 |
|
150 |
|
151 | text: Awaitable<this, NightwatchExpectResult>;
|
152 |
|
153 | |
154 |
|
155 |
|
156 | value: Awaitable<this, NightwatchExpectResult>;
|
157 |
|
158 | |
159 |
|
160 |
|
161 | visible: Awaitable<this, NightwatchExpectResult>;
|
162 |
|
163 | |
164 |
|
165 |
|
166 |
|
167 | domProperty(
|
168 | propertyName: string,
|
169 | message?: string
|
170 | ): Awaitable<this, NightwatchExpectResult>;
|
171 | }
|
172 |
|
173 | export interface ExpectSection extends ExpectAssertions<ExpectSection>, ExpectElement {}
|
174 |
|
175 | export interface ExpectElements extends ExpectAssertions<ExpectElements> {
|
176 | |
177 |
|
178 |
|
179 | count: this;
|
180 | }
|
181 |
|
182 | export interface ExpectTitle extends ExpectAssertions<ExpectTitle> {}
|
183 |
|
184 | export interface ExpectUrl extends ExpectAssertions<ExpectUrl> {}
|
185 |
|
186 | export interface Expect {
|
187 | (val: Element | WebElement | By | {[ELEMENT_KEY]: string}): ExpectElement;
|
188 | (val: any): Chai.Assertion;
|
189 |
|
190 | |
191 |
|
192 |
|
193 |
|
194 | cookie(name: string, domain?: string): ExpectCookie;
|
195 |
|
196 | |
197 |
|
198 |
|
199 | element(property: Definition): ExpectElement;
|
200 |
|
201 | |
202 |
|
203 |
|
204 | component(property: Definition): ExpectElement;
|
205 |
|
206 | |
207 |
|
208 |
|
209 | section(property: ScopedSelector): ExpectSection;
|
210 |
|
211 | |
212 |
|
213 |
|
214 |
|
215 | elements(property: ScopedSelector): ExpectElements;
|
216 |
|
217 | |
218 |
|
219 |
|
220 | title(): ExpectTitle;
|
221 |
|
222 | |
223 |
|
224 |
|
225 | url(): ExpectUrl;
|
226 | }
|