1 | import { By, ByHash, promise as wdpromise, WebDriver, WebElement } from 'selenium-webdriver';
|
2 | export declare class WebdriverBy {
|
3 | className: (className: string) => By;
|
4 | css: (css: string) => By;
|
5 | id: (id: string) => By;
|
6 | linkText: (linkText: string) => By;
|
7 | js: (js: string | Function, ...var_args: any[]) => By;
|
8 | name: (name: string) => By;
|
9 | partialLinkText: (partialText: string) => By;
|
10 | tagName: (tagName: string) => By;
|
11 | xpath: (xpath: string) => By;
|
12 | }
|
13 | export declare type WebDriverLocator = By | ByHash | Function;
|
14 | export interface ProtractorLocator {
|
15 | findElementsOverride: (driver: WebDriver, using: WebElement, rootSelector: string) => wdpromise.Promise<WebElement[]>;
|
16 | row?: (index: number) => Locator;
|
17 | column?: (index: string) => Locator;
|
18 | toString?: () => string;
|
19 | }
|
20 | export declare type Locator = ProtractorLocator | WebDriverLocator;
|
21 | export declare function isProtractorLocator(x: Locator): x is ProtractorLocator;
|
22 | /**
|
23 | * The Protractor Locators. These provide ways of finding elements in
|
24 | * Angular applications by binding, model, etc.
|
25 | *
|
26 | * @alias by
|
27 | * @extends {webdriver.By}
|
28 | */
|
29 | export declare class ProtractorBy extends WebdriverBy {
|
30 | [key: string]: any;
|
31 | /**
|
32 | * Add a locator to this instance of ProtractorBy. This locator can then be
|
33 | * used with element(by.locatorName(args)).
|
34 | *
|
35 | * @view
|
36 | * <button ng-click="doAddition()">Go!</button>
|
37 | *
|
38 | * @example
|
39 | * // Add the custom locator.
|
40 | * by.addLocator('buttonTextSimple',
|
41 | * function(buttonText, opt_parentElement, opt_rootSelector) {
|
42 | * // This function will be serialized as a string and will execute in the
|
43 | * // browser. The first argument is the text for the button. The second
|
44 | * // argument is the parent element, if any.
|
45 | * var using = opt_parentElement || document,
|
46 | * buttons = using.querySelectorAll('button');
|
47 | *
|
48 | * // Return an array of buttons with the text.
|
49 | * return Array.prototype.filter.call(buttons, function(button) {
|
50 | * return button.textContent === buttonText;
|
51 | * });
|
52 | * });
|
53 | *
|
54 | * // Use the custom locator.
|
55 | * element(by.buttonTextSimple('Go!')).click();
|
56 | *
|
57 | * @alias by.addLocator(locatorName, functionOrScript)
|
58 | * @param {string} name The name of the new locator.
|
59 | * @param {Function|string} script A script to be run in the context of
|
60 | * the browser. This script will be passed an array of arguments
|
61 | * that contains any args passed into the locator followed by the
|
62 | * element scoping the search and the css selector for the root angular
|
63 | * element. It should return an array of elements.
|
64 | */
|
65 | addLocator(name: string, script: Function | string): void;
|
66 | /**
|
67 | * Find an element by text binding. Does a partial match, so any elements
|
68 | * bound to variables containing the input string will be returned.
|
69 | *
|
70 | * Note: For AngularJS version 1.2, the interpolation brackets, (usually
|
71 | * {{}}), are optionally allowed in the binding description string. For
|
72 | * Angular version 1.3+, they are not allowed, and no elements will be found
|
73 | * if they are used.
|
74 | *
|
75 | * @view
|
76 | * <span>{{person.name}}</span>
|
77 | * <span ng-bind="person.email"></span>
|
78 | *
|
79 | * @example
|
80 | * var span1 = element(by.binding('person.name'));
|
81 | * expect(span1.getText()).toBe('Foo');
|
82 | *
|
83 | * var span2 = element(by.binding('person.email'));
|
84 | * expect(span2.getText()).toBe('foo@bar.com');
|
85 | *
|
86 | * // You can also use a substring for a partial match
|
87 | * var span1alt = element(by.binding('name'));
|
88 | * expect(span1alt.getText()).toBe('Foo');
|
89 | *
|
90 | * // This works for sites using Angular 1.2 but NOT 1.3
|
91 | * var deprecatedSyntax = element(by.binding('{{person.name}}'));
|
92 | *
|
93 | * @param {string} bindingDescriptor
|
94 | * @returns {ProtractorLocator} location strategy
|
95 | */
|
96 | binding(bindingDescriptor: string): ProtractorLocator;
|
97 | /**
|
98 | * Find an element by exact binding.
|
99 | *
|
100 | * @view
|
101 | * <span>{{ person.name }}</span>
|
102 | * <span ng-bind="person-email"></span>
|
103 | * <span>{{person_phone|uppercase}}</span>
|
104 | *
|
105 | * @example
|
106 | * expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);
|
107 | * expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);
|
108 | * expect(element(by.exactBinding('person')).isPresent()).toBe(false);
|
109 | * expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);
|
110 | * expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);
|
111 | * expect(element(by.exactBinding('phone')).isPresent()).toBe(false);
|
112 | *
|
113 | * @param {string} bindingDescriptor
|
114 | * @returns {ProtractorLocator} location strategy
|
115 | */
|
116 | exactBinding(bindingDescriptor: string): ProtractorLocator;
|
117 | /**
|
118 | * Find an element by ng-model expression.
|
119 | *
|
120 | * @alias by.model(modelName)
|
121 | * @view
|
122 | * <input type="text" ng-model="person.name">
|
123 | *
|
124 | * @example
|
125 | * var input = element(by.model('person.name'));
|
126 | * input.sendKeys('123');
|
127 | * expect(input.getAttribute('value')).toBe('Foo123');
|
128 | *
|
129 | * @param {string} model ng-model expression.
|
130 | * @returns {ProtractorLocator} location strategy
|
131 | */
|
132 | model(model: string): ProtractorLocator;
|
133 | /**
|
134 | * Find a button by text.
|
135 | *
|
136 | * @view
|
137 | * <button>Save</button>
|
138 | *
|
139 | * @example
|
140 | * element(by.buttonText('Save'));
|
141 | *
|
142 | * @param {string} searchText
|
143 | * @returns {ProtractorLocator} location strategy
|
144 | */
|
145 | buttonText(searchText: string): ProtractorLocator;
|
146 | /**
|
147 | * Find a button by partial text.
|
148 | *
|
149 | * @view
|
150 | * <button>Save my file</button>
|
151 | *
|
152 | * @example
|
153 | * element(by.partialButtonText('Save'));
|
154 | *
|
155 | * @param {string} searchText
|
156 | * @returns {ProtractorLocator} location strategy
|
157 | */
|
158 | partialButtonText(searchText: string): ProtractorLocator;
|
159 | private byRepeaterInner(exact, repeatDescriptor);
|
160 | /**
|
161 | * Find elements inside an ng-repeat.
|
162 | *
|
163 | * @view
|
164 | * <div ng-repeat="cat in pets">
|
165 | * <span>{{cat.name}}</span>
|
166 | * <span>{{cat.age}}</span>
|
167 | * </div>
|
168 | *
|
169 | * <div class="book-img" ng-repeat-start="book in library">
|
170 | * <span>{{$index}}</span>
|
171 | * </div>
|
172 | * <div class="book-info" ng-repeat-end>
|
173 | * <h4>{{book.name}}</h4>
|
174 | * <p>{{book.blurb}}</p>
|
175 | * </div>
|
176 | *
|
177 | * @example
|
178 | * // Returns the DIV for the second cat.
|
179 | * var secondCat = element(by.repeater('cat in pets').row(1));
|
180 | *
|
181 | * // Returns the SPAN for the first cat's name.
|
182 | * var firstCatName = element(by.repeater('cat in pets').
|
183 | * row(0).column('cat.name'));
|
184 | *
|
185 | * // Returns a promise that resolves to an array of WebElements from a column
|
186 | * var ages = element.all(
|
187 | * by.repeater('cat in pets').column('cat.age'));
|
188 | *
|
189 | * // Returns a promise that resolves to an array of WebElements containing
|
190 | * // all top level elements repeated by the repeater. For 2 pets rows
|
191 | * // resolves to an array of 2 elements.
|
192 | * var rows = element.all(by.repeater('cat in pets'));
|
193 | *
|
194 | * // Returns a promise that resolves to an array of WebElements containing
|
195 | * // all the elements with a binding to the book's name.
|
196 | * var divs = element.all(by.repeater('book in library').column('book.name'));
|
197 | *
|
198 | * // Returns a promise that resolves to an array of WebElements containing
|
199 | * // the DIVs for the second book.
|
200 | * var bookInfo = element.all(by.repeater('book in library').row(1));
|
201 | *
|
202 | * // Returns the H4 for the first book's name.
|
203 | * var firstBookName = element(by.repeater('book in library').
|
204 | * row(0).column('book.name'));
|
205 | *
|
206 | * // Returns a promise that resolves to an array of WebElements containing
|
207 | * // all top level elements repeated by the repeater. For 2 books divs
|
208 | * // resolves to an array of 4 elements.
|
209 | * var divs = element.all(by.repeater('book in library'));
|
210 | *
|
211 | * @param {string} repeatDescriptor
|
212 | * @returns {ProtractorLocator} location strategy
|
213 | */
|
214 | repeater(repeatDescriptor: string): ProtractorLocator;
|
215 | /**
|
216 | * Find an element by exact repeater.
|
217 | *
|
218 | * @view
|
219 | * <li ng-repeat="person in peopleWithRedHair"></li>
|
220 | * <li ng-repeat="car in cars | orderBy:year"></li>
|
221 | *
|
222 | * @example
|
223 | * expect(element(by.exactRepeater('person in
|
224 | * peopleWithRedHair')).isPresent())
|
225 | * .toBe(true);
|
226 | * expect(element(by.exactRepeater('person in
|
227 | * people')).isPresent()).toBe(false);
|
228 | * expect(element(by.exactRepeater('car in cars')).isPresent()).toBe(true);
|
229 | *
|
230 | * @param {string} repeatDescriptor
|
231 | * @returns {ProtractorLocator} location strategy
|
232 | */
|
233 | exactRepeater(repeatDescriptor: string): ProtractorLocator;
|
234 | /**
|
235 | * Find elements by CSS which contain a certain string.
|
236 | *
|
237 | * @view
|
238 | * <ul>
|
239 | * <li class="pet">Dog</li>
|
240 | * <li class="pet">Cat</li>
|
241 | * </ul>
|
242 | *
|
243 | * @example
|
244 | * // Returns the li for the dog, but not cat.
|
245 | * var dog = element(by.cssContainingText('.pet', 'Dog'));
|
246 | *
|
247 | * @param {string} cssSelector css selector
|
248 | * @param {string|RegExp} searchString text search
|
249 | * @returns {ProtractorLocator} location strategy
|
250 | */
|
251 | cssContainingText(cssSelector: string, searchText: string | RegExp): ProtractorLocator;
|
252 | /**
|
253 | * Find an element by ng-options expression.
|
254 | *
|
255 | * @alias by.options(optionsDescriptor)
|
256 | * @view
|
257 | * <select ng-model="color" ng-options="c for c in colors">
|
258 | * <option value="0" selected="selected">red</option>
|
259 | * <option value="1">green</option>
|
260 | * </select>
|
261 | *
|
262 | * @example
|
263 | * var allOptions = element.all(by.options('c for c in colors'));
|
264 | * expect(allOptions.count()).toEqual(2);
|
265 | * var firstOption = allOptions.first();
|
266 | * expect(firstOption.getText()).toEqual('red');
|
267 | *
|
268 | * @param {string} optionsDescriptor ng-options expression.
|
269 | * @returns {ProtractorLocator} location strategy
|
270 | */
|
271 | options(optionsDescriptor: string): ProtractorLocator;
|
272 | /**
|
273 | * Find an element by css selector within the Shadow DOM.
|
274 | *
|
275 | * @alias by.deepCss(selector)
|
276 | * @view
|
277 | * <div>
|
278 | * <span id="outerspan">
|
279 | * <"shadow tree">
|
280 | * <span id="span1"></span>
|
281 | * <"shadow tree">
|
282 | * <span id="span2"></span>
|
283 | * </>
|
284 | * </>
|
285 | * </div>
|
286 | * @example
|
287 | * var spans = element.all(by.deepCss('span'));
|
288 | * expect(spans.count()).toEqual(3);
|
289 | *
|
290 | * @param {string} selector a css selector within the Shadow DOM.
|
291 | * @returns {Locator} location strategy
|
292 | */
|
293 | deepCss(selector: string): Locator;
|
294 | }
|