1 | import * as http from "./http";
|
2 | import * as webdriver from "./index";
|
3 | import Symbols from "./lib/symbols";
|
4 | import * as remote from "./remote";
|
5 | export {};
|
6 |
|
7 | declare class Profile {
|
8 | constructor();
|
9 |
|
10 | addExtensions(): void;
|
11 |
|
12 | /**
|
13 | * @return {(!Promise<string>|undefined)} a promise for a base64 encoded
|
14 | * profile, or undefined if there's no data to include.
|
15 | */
|
16 | [Symbols.serialize](): Promise<string>;
|
17 | }
|
18 |
|
19 | export enum Context {
|
20 | CONTENT = "content",
|
21 | CHROME = "chrome",
|
22 | }
|
23 |
|
24 | /**
|
25 | * Configuration options for the FirefoxDriver.
|
26 | */
|
27 | export class Options extends webdriver.Capabilities {
|
28 | /**
|
29 | * @param {(Capabilities|Map<string, ?>|Object)=} other Another set of
|
30 | * capabilities to initialize this instance from.
|
31 | */
|
32 | constructor(other?: webdriver.Capabilities | Map<string, any> | object);
|
33 |
|
34 | /**
|
35 | * @return {!Object}
|
36 | */
|
37 | firefoxOptions_(): object;
|
38 |
|
39 | /**
|
40 | * Sets the profile to use. The profile may be specified as a
|
41 | * {@link Profile} object or as the path to an existing Firefox profile to use
|
42 | * as a template.
|
43 | *
|
44 | * @param {(string|!Profile)} profile The profile to use.
|
45 | * @return {!Options} A self reference.
|
46 | */
|
47 | setProfile(profile: string | Profile): Options;
|
48 |
|
49 | /**
|
50 | * @param {string} key the preference key.
|
51 | * @param {(string|number|boolean)} value the preference value.
|
52 | * @return {!Options} A self reference.
|
53 | * @throws {TypeError} if either the key or value has an invalid type.
|
54 | */
|
55 | setPreference(key: string, value: string | number | boolean): Options;
|
56 |
|
57 | /**
|
58 | * Add extensions that should be installed when starting Firefox.
|
59 | *
|
60 | * @param {...string} paths The paths to the extension XPI files to install.
|
61 | * @return {!Options} A self reference.
|
62 | */
|
63 | addExtensions(...paths: string[]): Options;
|
64 |
|
65 | /**
|
66 | * Sets the initial window size.
|
67 | *
|
68 | * @param {{width: number, height: number}} size The desired window size.
|
69 | * @return {!Options} A self reference.
|
70 | * @throws {TypeError} if width or height is unspecified, not a number, or
|
71 | * less than or equal to 0.
|
72 | */
|
73 | windowSize(size: { width: number; height: number }): Options;
|
74 |
|
75 | /**
|
76 | * Specify additional command line arguments that should be used when starting
|
77 | * the Firefox browser.
|
78 | *
|
79 | * @param {...(string|!Array<string>)} args The arguments to include.
|
80 | * @return {!Options} A self reference.
|
81 | */
|
82 | addArguments(...args: string[]): Options;
|
83 |
|
84 | /**
|
85 | * Sets the binary to use. The binary may be specified as the path to a
|
86 | * Firefox executable.
|
87 | *
|
88 | * @param {(string)} binary The binary to use.
|
89 | * @return {!Options} A self reference.
|
90 | * @throws {TypeError} If `binary` is an invalid type.
|
91 | */
|
92 | setBinary(binary: string): Options;
|
93 |
|
94 | /**
|
95 | * Enables Mobile start up features
|
96 | *
|
97 | * @param {string} androidPackage The package to use
|
98 | * @return {!Options} A self reference
|
99 | */
|
100 | enableMobile(androidPackage: string, androidActivity: string, deviceSerial: string): Options;
|
101 |
|
102 | /**
|
103 | * Enables moz:debuggerAddress for firefox cdp
|
104 | */
|
105 | enableDebugger(): void;
|
106 |
|
107 | /**
|
108 | * Enable bidi connection
|
109 | * @returns {!Capabilities}
|
110 | */
|
111 | enableBidi(): webdriver.Capabilities;
|
112 | }
|
113 |
|
114 | /**
|
115 | * A WebDriver client for Firefox.
|
116 | */
|
117 | export class Driver extends webdriver.WebDriver {
|
118 | /**
|
119 | * Creates a new Firefox session.
|
120 | *
|
121 | * @param {(Options|Capabilities|Object)=} opt_config The
|
122 | * configuration options for this driver, specified as either an
|
123 | * {@link Options} or {@link Capabilities}, or as a raw hash object.
|
124 | * @param {(http.Executor|remote.DriverService)=} opt_executor Either a
|
125 | * pre-configured command executor to use for communicating with an
|
126 | * externally managed remote end (which is assumed to already be running),
|
127 | * or the `DriverService` to use to start the geckodriver in a child
|
128 | * process.
|
129 | *
|
130 | * If an executor is provided, care should e taken not to use reuse it with
|
131 | * other clients as its internal command mappings will be updated to support
|
132 | * Firefox-specific commands.
|
133 | *
|
134 | * _This parameter may only be used with Mozilla's GeckoDriver._
|
135 | *
|
136 | * @throws {Error} If a custom command executor is provided and the driver is
|
137 | * configured to use the legacy FirefoxDriver from the Selenium project.
|
138 | * @return {!Driver} A new driver instance.
|
139 | */
|
140 | static createSession(
|
141 | opt_config?: Options | webdriver.Capabilities | Object,
|
142 | opt_executor?: http.Executor | remote.DriverService,
|
143 | ): Driver;
|
144 |
|
145 | /**
|
146 | * This function is a no-op as file detectors are not supported by this
|
147 | * implementation.
|
148 | * @override
|
149 | */
|
150 | setFileDetector(): void;
|
151 |
|
152 | /**
|
153 | * Get the context that is currently in effect.
|
154 | *
|
155 | * @return {!Promise<Context>} Current context.
|
156 | */
|
157 | getContext(): Promise<Context>;
|
158 |
|
159 | /**
|
160 | * Changes target context for commands between chrome- and content.
|
161 | *
|
162 | * Changing the current context has a stateful impact on all subsequent
|
163 | * commands. The {@link Context.CONTENT} context has normal web
|
164 | * platform document permissions, as if you would evaluate arbitrary
|
165 | * JavaScript. The {@link Context.CHROME} context gets elevated
|
166 | * permissions that lets you manipulate the browser chrome itself,
|
167 | * with full access to the XUL toolkit.
|
168 | *
|
169 | * Use your powers wisely.
|
170 | *
|
171 | * @param {!Promise<void>} ctx The context to switch to.
|
172 | */
|
173 | setContext(ctx: Context): Promise<void>;
|
174 |
|
175 | /**
|
176 | * Installs a new addon with the current session. This function will return an
|
177 | * ID that may later be used to {@linkplain #uninstallAddon uninstall} the
|
178 | * addon.
|
179 | *
|
180 | * @param {string} path Path on the local filesystem to the web extension to
|
181 | * install.
|
182 | * @param {boolean} temporary Flag indicating whether the extension should be
|
183 | * installed temporarily - gets removed on restart
|
184 | * @return {!Promise<string>} A promise that will resolve to an ID for the
|
185 | * newly installed addon.
|
186 | * @see #uninstallAddon
|
187 | */
|
188 | installAddon(path: string, temporary: boolean): Promise<string>;
|
189 |
|
190 | /**
|
191 | * Uninstalls an addon from the current browser session's profile.
|
192 | *
|
193 | * @param {(string|!Promise<string>)} id ID of the addon to uninstall.
|
194 | * @return {!Promise} A promise that will resolve when the operation has
|
195 | * completed.
|
196 | * @see #installAddon
|
197 | */
|
198 | uninstallAddon(id: string | Promise<string>): Promise<void>;
|
199 |
|
200 | /**
|
201 | * Take full page screenshot of the visible region
|
202 | *
|
203 | * @return {!Promise<string>} A promise that will be
|
204 | * resolved to the screenshot as a base-64 encoded PNG.
|
205 | */
|
206 | takeFullPageScreenshot(): Promise<string>;
|
207 | }
|
208 |
|
209 | /**
|
210 | * Creates {@link selenium-webdriver/remote.DriverService} instances that manage
|
211 | * a [geckodriver](https://github.com/mozilla/geckodriver) server in a child
|
212 | * process.
|
213 | */
|
214 | export class ServiceBuilder extends remote.DriverService.Builder {
|
215 | /**
|
216 | * @param {string=} opt_exe Path to the server executable to use. If omitted,
|
217 | * the builder will attempt to locate the geckodriver on the system PATH.
|
218 | */
|
219 | constructor(opt_exe?: string);
|
220 |
|
221 | /**
|
222 | * Enables verbose logging.
|
223 | *
|
224 | * @param {boolean=} opt_trace Whether to enable trace-level logging. By
|
225 | * default, only debug logging is enabled.
|
226 | * {!ServiceBuilder} A self reference.
|
227 | */
|
228 | enableVerboseLogging(opt_trace?: boolean): ServiceBuilder;
|
229 | }
|
230 |
|
231 | /**
|
232 | * Provides methods for locating the executable for a Firefox release channel
|
233 | * on Windows and MacOS. For other systems (i.e. Linux), Firefox will always
|
234 | * be located on the system PATH.
|
235 | * @deprecated Instead of using this class, you should configure the
|
236 | * {@link Options} with the appropriate binary location or let Selenium
|
237 | * Manager handle it for you.
|
238 | * @final
|
239 | */
|
240 | export class Channel {
|
241 | /**
|
242 | * @param {string} darwin The path to check when running on MacOS.
|
243 | * @param {string} win32 The path to check when running on Windows.
|
244 | */
|
245 | constructor(darwin: string, win32: string);
|
246 |
|
247 | /**
|
248 | * Attempts to locate the Firefox executable for this release channel. This
|
249 | * will first check the default installation location for the channel before
|
250 | * checking the user's PATH. The returned promise will be rejected if Firefox
|
251 | * can not be found.
|
252 | *
|
253 | * @return {!Promise<string>} A promise for the location of the located
|
254 | * Firefox executable.
|
255 | */
|
256 | locate(): Promise<string>;
|
257 | }
|