Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/webdriver-bootstrap.js
2864 views
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 Bootstrap file that loads all of the WebDriver scripts in the
20
* correct order. Once loaded, pages can use {@code goog.require} statements
21
* from Google DocType to load additional files as needed.
22
*
23
* Example Usage:
24
*
25
* <html>
26
* <head>
27
* <script src="webdriver-bootstrap.js"></script>
28
* <script>
29
* goog.require('goog.debug.Logger');
30
* </script>
31
* <script>
32
* window.onload = function() {
33
* goog.debug.Logger.getLogger('').info(
34
* 'The page has finished loading');
35
* };
36
* </script>
37
* </head>
38
* <body></body>
39
* </html>
40
* @author [email protected] (Jason Leyba)
41
*/
42
43
(function() {
44
// goog.provide will do this for us, but this makes the IDE stop complaining
45
// about an undefined symbol.
46
window.webdriver = {};
47
48
let scripts = document.getElementsByTagName('script');
49
let directoryPath = './';
50
let thisFile = 'webdriver-bootstrap.js';
51
52
for (let i = 0; i < scripts.length; i++) {
53
let src = scripts[i].src;
54
let len = src.length;
55
if (src.substr(len - thisFile.length) == thisFile) {
56
directoryPath = src.substr(0, len - thisFile.length);
57
break;
58
}
59
}
60
61
// All of the files to load. Files are specified in the order they must be
62
// loaded, NOT alphabetical order.
63
const webdriverFiles = [
64
'../../third_party/closure/goog/base.js',
65
'deps.js'
66
];
67
68
for (let j = 0; j < webdriverFiles.length; j++) {
69
document.write('<script type="text/javascript" src="' +
70
directoryPath + webdriverFiles[j] + '"></script>');
71
}
72
})();
73
74