selenium-webdriver 4.0.0-alpha.4 → 4.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.eslintrc.js +27 -0
  2. package/.prettierrc +4 -0
  3. package/CHANGES.md +22 -1
  4. package/README.md +4 -4
  5. package/chrome.js +72 -590
  6. package/chromium.js +1024 -0
  7. package/devtools/CDPConnection.js +37 -0
  8. package/devtools/generator/protocol-dts-generator.js +429 -0
  9. package/edge.js +124 -86
  10. package/firefox.js +201 -202
  11. package/http/index.js +131 -115
  12. package/http/util.js +56 -64
  13. package/ie.js +180 -104
  14. package/index.js +246 -199
  15. package/io/exec.js +34 -39
  16. package/io/index.js +141 -151
  17. package/io/zip.js +75 -65
  18. package/lib/README +5 -0
  19. package/lib/actions.js +138 -121
  20. package/lib/atoms/find-elements.js +123 -0
  21. package/lib/atoms/get-attribute.js +79 -60
  22. package/lib/atoms/is-displayed.js +72 -73
  23. package/{example/chrome_mobile_emulation.js → lib/atoms/make-atoms-module.js} +16 -23
  24. package/lib/by.js +192 -65
  25. package/lib/capabilities.js +82 -78
  26. package/lib/command.js +18 -20
  27. package/lib/error.js +134 -168
  28. package/lib/http.js +324 -230
  29. package/lib/input.js +325 -302
  30. package/lib/logging.js +127 -138
  31. package/lib/promise.js +60 -66
  32. package/lib/proxy.js +31 -41
  33. package/lib/session.js +12 -15
  34. package/lib/symbols.js +3 -4
  35. package/lib/until.js +162 -162
  36. package/lib/webdriver.js +733 -522
  37. package/net/index.js +30 -36
  38. package/net/portprober.js +31 -144
  39. package/opera.js +406 -0
  40. package/package.json +18 -11
  41. package/proxy.js +2 -2
  42. package/remote/index.js +190 -187
  43. package/safari.js +40 -49
  44. package/LICENSE +0 -202
  45. package/NOTICE +0 -2
  46. package/example/chrome_android.js +0 -42
  47. package/example/firefox_channels.js +0 -77
  48. package/example/google_search.js +0 -50
  49. package/example/google_search_test.js +0 -72
  50. package/example/headless.js +0 -55
  51. package/example/logging.js +0 -68
  52. package/testing/index.js +0 -498
package/safari.js CHANGED
@@ -19,19 +19,13 @@
19
19
  * @fileoverview Defines a WebDriver client for Safari.
20
20
  */
21
21
 
22
- 'use strict';
23
-
24
- const command = require('./lib/command');
25
- const error = require('./lib/error');
26
- const http = require('./http');
27
- const io = require('./io');
28
- const portprober = require('./net/portprober');
29
- const promise = require('./lib/promise');
30
- const remote = require('./remote');
31
- const Symbols = require('./lib/symbols');
32
- const webdriver = require('./lib/webdriver');
33
- const {Browser, Capabilities, Capability} = require('./lib/capabilities');
22
+ 'use strict'
34
23
 
24
+ const http = require('./http')
25
+ const io = require('./io')
26
+ const remote = require('./remote')
27
+ const webdriver = require('./lib/webdriver')
28
+ const { Browser, Capabilities } = require('./lib/capabilities')
35
29
 
36
30
  /**
37
31
  * _Synchronously_ attempts to locate the IE driver executable on the current
@@ -41,25 +35,25 @@ const {Browser, Capabilities, Capability} = require('./lib/capabilities');
41
35
  */
42
36
  function locateSynchronously() {
43
37
  return process.platform === 'darwin'
44
- ? io.findInPath('safaridriver', true) : null;
38
+ ? io.findInPath('safaridriver', true)
39
+ : null
45
40
  }
46
41
 
47
-
48
42
  /**
49
43
  * @return {string} .
50
44
  * @throws {Error}
51
45
  */
52
46
  function findSafariDriver() {
53
- let exe = locateSynchronously();
47
+ let exe = locateSynchronously()
54
48
  if (!exe) {
55
49
  throw Error(
56
50
  `The safaridriver executable could not be found on the current PATH.
57
- Please ensure you are using Safari 10.0 or above.`);
51
+ Please ensure you are using Safari 10.0 or above.`
52
+ )
58
53
  }
59
- return exe;
54
+ return exe
60
55
  }
61
56
 
62
-
63
57
  /**
64
58
  * Creates {@link selenium-webdriver/remote.DriverService} instances that manage
65
59
  * a [safaridriver] server in a child process.
@@ -72,14 +66,13 @@ class ServiceBuilder extends remote.DriverService.Builder {
72
66
  * the builder will attempt to locate the safaridriver on the system PATH.
73
67
  */
74
68
  constructor(opt_exe) {
75
- super(opt_exe || findSafariDriver());
76
- this.setLoopback(true); // Required.
69
+ super(opt_exe || findSafariDriver())
70
+ this.setLoopback(true) // Required.
77
71
  }
78
72
  }
79
73
 
80
-
81
- const OPTIONS_CAPABILITY_KEY = 'safari.options';
82
- const TECHNOLOGY_PREVIEW_OPTIONS_KEY = 'technologyPreview';
74
+ const OPTIONS_CAPABILITY_KEY = 'safari.options'
75
+ const TECHNOLOGY_PREVIEW_OPTIONS_KEY = 'technologyPreview'
83
76
 
84
77
  /**
85
78
  * Configuration options specific to the {@link Driver SafariDriver}.
@@ -90,13 +83,13 @@ class Options extends Capabilities {
90
83
  * capabilities to initialize this instance from.
91
84
  */
92
85
  constructor(other = undefined) {
93
- super(other);
86
+ super(other)
94
87
 
95
88
  /** @private {!Object} */
96
- this.options_ = this.get(OPTIONS_CAPABILITY_KEY) || {};
89
+ this.options_ = this.get(OPTIONS_CAPABILITY_KEY) || {}
97
90
 
98
- this.set(OPTIONS_CAPABILITY_KEY, this.options_);
99
- this.setBrowserName(Browser.SAFARI);
91
+ this.set(OPTIONS_CAPABILITY_KEY, this.options_)
92
+ this.setBrowserName(Browser.SAFARI)
100
93
  }
101
94
 
102
95
  /**
@@ -107,8 +100,8 @@ class Options extends Capabilities {
107
100
  * @return {!Options} A self reference.
108
101
  */
109
102
  setTechnologyPreview(useTechnologyPreview) {
110
- this.options_[TECHNOLOGY_PREVIEW_OPTIONS_KEY] = !!useTechnologyPreview;
111
- return this;
103
+ this.options_[TECHNOLOGY_PREVIEW_OPTIONS_KEY] = !!useTechnologyPreview
104
+ return this
112
105
  }
113
106
  }
114
107
 
@@ -118,21 +111,19 @@ class Options extends Capabilities {
118
111
  */
119
112
  function useTechnologyPreview(o) {
120
113
  if (o instanceof Capabilities) {
121
- let options = o.get(OPTIONS_CAPABILITY_KEY);
122
- return !!(options && options[TECHNOLOGY_PREVIEW_OPTIONS_KEY]);
114
+ let options = o.get(OPTIONS_CAPABILITY_KEY)
115
+ return !!(options && options[TECHNOLOGY_PREVIEW_OPTIONS_KEY])
123
116
  }
124
117
 
125
118
  if (o && typeof o === 'object') {
126
- return !!o[TECHNOLOGY_PREVIEW_OPTIONS_KEY];
119
+ return !!o[TECHNOLOGY_PREVIEW_OPTIONS_KEY]
127
120
  }
128
121
 
129
- return false;
122
+ return false
130
123
  }
131
124
 
132
-
133
125
  const SAFARIDRIVER_TECHNOLOGY_PREVIEW_EXE =
134
- '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver';
135
-
126
+ '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
136
127
 
137
128
  /**
138
129
  * A WebDriver client for Safari. This class should never be instantiated
@@ -151,27 +142,27 @@ class Driver extends webdriver.WebDriver {
151
142
  * @return {!Driver} A new driver instance.
152
143
  */
153
144
  static createSession(options) {
154
- let caps = options || new Options();
145
+ let caps = options || new Options()
155
146
 
156
- let exe;
147
+ let exe
157
148
  if (useTechnologyPreview(caps.get(OPTIONS_CAPABILITY_KEY))) {
158
- exe = SAFARIDRIVER_TECHNOLOGY_PREVIEW_EXE;
149
+ exe = SAFARIDRIVER_TECHNOLOGY_PREVIEW_EXE
159
150
  }
160
151
 
161
- let service = new ServiceBuilder(exe).build();
152
+ let service = new ServiceBuilder(exe).build()
162
153
  let executor = new http.Executor(
163
- service.start().then(url => new http.HttpClient(url)));
154
+ service.start().then((url) => new http.HttpClient(url))
155
+ )
164
156
 
165
- return /** @type {!Driver} */(super.createSession(
166
- executor, caps, () => service.kill()));
157
+ return /** @type {!Driver} */ (super.createSession(executor, caps, () =>
158
+ service.kill()
159
+ ))
167
160
  }
168
161
  }
169
162
 
170
-
171
163
  // Public API
172
164
 
173
-
174
- exports.Driver = Driver;
175
- exports.Options = Options;
176
- exports.ServiceBuilder = ServiceBuilder;
177
- exports.locateSynchronously = locateSynchronously;
165
+ exports.Driver = Driver
166
+ exports.Options = Options
167
+ exports.ServiceBuilder = ServiceBuilder
168
+ exports.locateSynchronously = locateSynchronously
package/LICENSE DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright 2019 Software Freedom Conservancy (SFC)
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
package/NOTICE DELETED
@@ -1,2 +0,0 @@
1
- Copyright 2011-2019 Software Freedom Conservancy
2
- Copyright 2004-2011 Selenium committers
@@ -1,42 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- /**
19
- * @fileoverview A basic example of working with Chrome on Android. Before
20
- * running this example, you must start adb and connect a device (or start an
21
- * AVD).
22
- */
23
-
24
- 'use strict';
25
-
26
- const {Builder, By, Key, until} = require('..');
27
- const {Options} = require('../chrome');
28
-
29
- (async function() {
30
- let driver;
31
- try {
32
- driver = await new Builder()
33
- .forBrowser('chrome')
34
- .setChromeOptions(new Options().androidChrome())
35
- .build();
36
- await driver.get('http://www.google.com/ncr');
37
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
38
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
39
- } finally {
40
- await driver && driver.quit();
41
- }
42
- })().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
@@ -1,77 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- /**
19
- * @fileoverview This is an example of working with the different Firefox
20
- * release channels. Before running this example, you will need to have
21
- * installed Firefox's release, nightly, and developer editions:
22
- *
23
- * - https://www.mozilla.org/en-US/firefox/channel/desktop/#aurora
24
- * - https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly
25
- */
26
-
27
-
28
- 'use strict';
29
-
30
- const {Builder, By, Key, promise, until} = require('..');
31
- const {Channel, Options} = require('../firefox');
32
-
33
- let i = 0;
34
- function resposition(driver) {
35
- return driver.manage().window().setRect({
36
- width: 600,
37
- height: 400,
38
- x: 300 * (i++),
39
- y: 0
40
- });
41
- }
42
-
43
- async function doSearch(driver) {
44
- try {
45
- // Start on the base about page.
46
- await driver.get('about:')
47
- // Reposition so users can see the three windows.
48
- await resposition(driver);
49
- // Pause so users can see the magic.
50
- await promise.delayed(750);
51
- // Now do the rest.
52
- await driver.get('http://www.google.com/ncr');
53
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
54
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
55
- console.log('Success!');
56
- } catch (ex) {
57
- console.log('An error occured! ' + ex);
58
- } finally {
59
- await driver.quit();
60
- }
61
- }
62
-
63
- function createDriver(channel) {
64
- let options = new Options().setBinary(channel);
65
- return new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
66
- }
67
-
68
- Promise.all([
69
- doSearch(createDriver(Channel.RELEASE)),
70
- doSearch(createDriver(Channel.AURORA)), // Developer Edition.
71
- doSearch(createDriver(Channel.NIGHTLY)),
72
- ]).then(_ => {
73
- console.log('All done!');
74
- }, err => {
75
- console.error('An error occured! ' + err);
76
- setTimeout(() => {throw err}, 0);
77
- });
@@ -1,50 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- /**
19
- * @fileoverview An example WebDriver script.
20
- *
21
- * Before running this script, ensure that Mozilla's geckodriver is present on
22
- * your system PATH: <https://github.com/mozilla/geckodriver/releases>
23
- *
24
- * Usage:
25
- * // Default behavior
26
- * node selenium-webdriver/example/google_search.js
27
- *
28
- * // Target Chrome locally; the chromedriver must be on your PATH
29
- * SELENIUM_BROWSER=chrome node selenium-webdriver/example/google_search.js
30
- *
31
- * // Use a local copy of the standalone Selenium server
32
- * SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
33
- * node selenium-webdriver/example/google_search.js
34
- *
35
- * // Target a remote Selenium server
36
- * SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
37
- * node selenium-webdriver/example/google_search.js
38
- */
39
-
40
- const {Builder, By, Key, until} = require('..');
41
-
42
- var driver = new Builder()
43
- .forBrowser('firefox')
44
- .build();
45
-
46
- driver.get('http://www.google.com/ncr')
47
- .then(_ =>
48
- driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
49
- .then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
50
- .then(_ => driver.quit());
@@ -1,72 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- /**
19
- * @fileoverview An example test that may be run using Mocha.
20
- *
21
- * This example uses the `selenium-webdriver/testing.suite` function, which will
22
- * automatically run tests against every available WebDriver browser on the
23
- * current system. Alternatively, you may use the `SELENIUM_BROWSER`
24
- * environment variable to narrow the scope at runtime.
25
- *
26
- * Usage:
27
- *
28
- * # Automatically determine which browsers to run against.
29
- * mocha -t 10000 selenium-webdriver/example/google_search_test.js
30
- *
31
- * # Configure tests to only run against Google Chrome.
32
- * SELENIUM_BROWSER=chrome \
33
- * mocha -t 10000 selenium-webdriver/example/google_search_test.js
34
- */
35
-
36
- const assert = require('assert');
37
-
38
- const {Browser, By, Key, until} = require('..');
39
- const {ignore, suite} = require('../testing');
40
-
41
- suite(function(env) {
42
- describe('Google Search', function() {
43
- let driver;
44
-
45
- before(async function() {
46
- // env.builder() returns a Builder instance preconfigured for the
47
- // envrionment's target browser (you may still define browser specific
48
- // options if necessary (i.e. firefox.Options or chrome.Options)).
49
- driver = await env.builder().build();
50
- });
51
-
52
- it('demo', async function() {
53
- await driver.get('https://www.google.com/ncr');
54
- await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
55
- await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
56
- });
57
-
58
- // The ignore function returns wrappers around describe & it that will
59
- // suppress tests if the provided predicate returns true. You may provide
60
- // any synchronous predicate. The env.browsers(...) function generates a
61
- // predicate that will suppress tests if the env targets one of the
62
- // specified browsers.
63
- //
64
- // This example is always configured to skip Chrome.
65
- ignore(env.browsers(Browser.CHROME)).it('demo 2', async function() {
66
- await driver.get('https://www.google.com/ncr');
67
- await driver.wait(until.urlIs('https://www.google.com/'), 1500);
68
- });
69
-
70
- after(() => driver && driver.quit());
71
- });
72
- });
@@ -1,55 +0,0 @@
1
- // Licensed to the Software Freedom Conservancy (SFC) under one
2
- // or more contributor license agreements. See the NOTICE file
3
- // distributed with this work for additional information
4
- // regarding copyright ownership. The SFC licenses this file
5
- // to you under the Apache License, Version 2.0 (the
6
- // "License"); you may not use this file except in compliance
7
- // with the License. You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing,
12
- // software distributed under the License is distributed on an
13
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- // KIND, either express or implied. See the License for the
15
- // specific language governing permissions and limitations
16
- // under the License.
17
-
18
- /**
19
- * @fileoverview An example of running Chrome or Firefox in headless mode.
20
- *
21
- * To run with Chrome, ensure you have Chrome 59+ installed and that
22
- * chromedriver 2.30+ is present on your system PATH:
23
- * <https://sites.google.com/a/chromium.org/chromedriver/downloads>
24
- *
25
- * SELENIUM_BROWSER=chrome node selenium-webdriver/example/headless.js
26
- *
27
- * To run with Firefox, ensure you have Firefox 57+ installed and that
28
- * geckodriver 0.19.0+ is present on your system PATH:
29
- * <https://github.com/mozilla/geckodriver/releases>
30
- *
31
- * SELENIUM_BROWSER=firefox node selenium-webdriver/example/headless.js
32
- */
33
-
34
- const chrome = require('../chrome');
35
- const firefox = require('../firefox');
36
- const {Builder, By, Key, until} = require('..');
37
-
38
- const width = 640;
39
- const height = 480;
40
-
41
- let driver = new Builder()
42
- .forBrowser('chrome')
43
- .setChromeOptions(
44
- new chrome.Options().headless().windowSize({width, height}))
45
- .setFirefoxOptions(
46
- new firefox.Options().headless().windowSize({width, height}))
47
- .build();
48
-
49
- driver.get('http://www.google.com/ncr')
50
- .then(_ =>
51
- driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
52
- .then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
53
- .then(
54
- _ => driver.quit(),
55
- e => driver.quit().then(() => { throw e; }));