1 | import { Locator, WebDriver } from '../';
|
2 |
|
3 | /**
|
4 | * Typings for lib/by.js
|
5 | * Describes a mechanism for locating an element on the page.
|
6 | * @final
|
7 | */
|
8 | export class By {
|
9 | /**
|
10 | * @param {string} using the name of the location strategy to use.
|
11 | * @param {string} value the value to search for.
|
12 | */
|
13 | constructor(using: string, value: string);
|
14 |
|
15 | using: string;
|
16 | value: string;
|
17 |
|
18 | /**
|
19 | * Locates elements that have a specific class name.
|
20 | *
|
21 | * @param {string} name The class name to search for.
|
22 | * new locator.
{!By} The |
23 | * //www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes
http: |
24 | * //www.w3.org/TR/CSS2/selector.html#class-html
http: |
25 | */
|
26 | static className(name: string): By;
|
27 |
|
28 | /**
|
29 | * Locates elements using a CSS selector.
|
30 | *
|
31 | * @param {string} selector The CSS selector to use.
|
32 | * @return {!By} The new locator.
|
33 | * @see http://www.w3.org/TR/CSS2/selector.html
|
34 | */
|
35 | static css(selector: string): By;
|
36 |
|
37 | /**
|
38 | * Locates eleemnts by the ID attribute. This locator uses the CSS selector
|
39 | * `*[id='$ID']`, _not_ `document.getElementById`.
|
40 | *
|
41 | * @param {string} id The ID to search for.
|
42 | * @return {!By} The new locator.
|
43 | */
|
44 | static id(id: string): By;
|
45 |
|
46 | /**
|
47 | * Locates link elements whose
|
48 | * {@linkplain WebElement#getText visible text} matches the given
|
49 | * string.
|
50 | *
|
51 | * @param {string} text The link text to search for.
|
52 | * @return {!By} The new locator.
|
53 | */
|
54 | static linkText(text: string): By;
|
55 |
|
56 | /**
|
57 | * Locates an elements by evaluating a
|
58 | * {@linkplain WebDriver#executeScript JavaScript expression}.
|
59 | * The result of this expression must be an element or list of elements.
|
60 | *
|
61 | * @param {!(string|Function)} script The script to execute.
|
62 | * @param {...*} var_args The arguments to pass to the script.
|
63 | * @return {function(!./WebDriver): !./Promise}
|
64 | * A new JavaScript-based locator function.
|
65 | */
|
66 | static js(script: string|Function, ...var_args: any[]): (webdriver: WebDriver) => Promise<any>;
|
67 |
|
68 | /**
|
69 | * Locates elements whose `name` attribute has the given value.
|
70 | *
|
71 | * @param {string} name The name attribute to search for.
|
72 | * @return {!By} The new locator.
|
73 | */
|
74 | static name(name: string): By;
|
75 |
|
76 | /**
|
77 | * Locates link elements whose
|
78 | * {@linkplain WebElement#getText visible text} contains the given
|
79 | * substring.
|
80 | *
|
81 | * @param {string} text The substring to check for in a link's visible text.
|
82 | * @return {!By} The new locator.
|
83 | */
|
84 | static partialLinkText(text: string): By;
|
85 |
|
86 | /**
|
87 | * Locates elements with a given tag name.
|
88 | *
|
89 | * @param {string} name The tag name to search for.
|
90 | * @return {!By} The new locator.
|
91 | * @deprecated Use {@link By.css() By.css(tagName)} instead.
|
92 | */
|
93 | static tagName(name: string): By;
|
94 |
|
95 | /**
|
96 | * Locates elements matching a XPath selector. Care should be taken when
|
97 | * using an XPath selector with a {@link WebElement} as WebDriver
|
98 | * will respect the context in the specified in the selector. For example,
|
99 | * given the selector `//div`, WebDriver will search from the document root
|
100 | * regardless of whether the locator was used with a WebElement.
|
101 | *
|
102 | * @param {string} xpath The XPath selector to use.
|
103 | * @return {!By} The new locator.
|
104 | * @see http://www.w3.org/TR/xpath/
|
105 | */
|
106 | static xpath(xpath: string): By;
|
107 |
|
108 | /** @override */
|
109 | toString(): string;
|
110 | }
|
111 |
|
112 | /**
|
113 | * Short-hand expressions for the primary element locator strategies.
|
114 | * For example the following two statements are equivalent:
|
115 | *
|
116 | * var e1 = driver.findElement(By.id('foo'));
|
117 | * var e2 = driver.findElement({id: 'foo'});
|
118 | *
|
119 | * Care should be taken when using JavaScript minifiers (such as the
|
120 | * Closure compiler), as locator hashes will always be parsed using
|
121 | * the un-obfuscated properties listed.
|
122 | *
|
123 | * @typedef {(
|
124 | * {className: string}|
|
125 | * {css: string}|
|
126 | * {id: string}|
|
127 | * {js: string}|
|
128 | * {linkText: string}|
|
129 | * {name: string}|
|
130 | * {partialLinkText: string}|
|
131 | * {tagName: string}|
|
132 | * {xpath: string})}
|
133 | */
|
134 | export type ByHash = {
|
135 | className: string
|
136 | } | {css: string} |
|
137 | {id: string} | {js: string} | {linkText: string} | {name: string} | {partialLinkText: string} |
|
138 | {tagName: string} | {xpath: string};
|
139 |
|
140 | export function checkedLocator(locator: Locator): By;
|