UNPKG

selenium-webdriver

Version:

The official WebDriver JavaScript bindings from the Selenium project

1 lines 6.7 kB
<!DOCTYPE html><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"><meta http-equiv="Content-Language" content="en"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>executors.js</title><link href="../dossier.css" rel="stylesheet" type="text/css"><header><div><form><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></header><main><article class="srcfile"><h1>executors.js</h1><div><table><tr><td><a id="l1"></a><a href="#l1">1</a><td>// Licensed to the Software Freedom Conservancy (SFC) under one<tr><td><a id="l2"></a><a href="#l2">2</a><td>// or more contributor license agreements. See the NOTICE file<tr><td><a id="l3"></a><a href="#l3">3</a><td>// distributed with this work for additional information<tr><td><a id="l4"></a><a href="#l4">4</a><td>// regarding copyright ownership. The SFC licenses this file<tr><td><a id="l5"></a><a href="#l5">5</a><td>// to you under the Apache License, Version 2.0 (the<tr><td><a id="l6"></a><a href="#l6">6</a><td>// &quot;License&quot;); you may not use this file except in compliance<tr><td><a id="l7"></a><a href="#l7">7</a><td>// with the License. You may obtain a copy of the License at<tr><td><a id="l8"></a><a href="#l8">8</a><td>//<tr><td><a id="l9"></a><a href="#l9">9</a><td>// http://www.apache.org/licenses/LICENSE-2.0<tr><td><a id="l10"></a><a href="#l10">10</a><td>//<tr><td><a id="l11"></a><a href="#l11">11</a><td>// Unless required by applicable law or agreed to in writing,<tr><td><a id="l12"></a><a href="#l12">12</a><td>// software distributed under the License is distributed on an<tr><td><a id="l13"></a><a href="#l13">13</a><td>// &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY<tr><td><a id="l14"></a><a href="#l14">14</a><td>// KIND, either express or implied. See the License for the<tr><td><a id="l15"></a><a href="#l15">15</a><td>// specific language governing permissions and limitations<tr><td><a id="l16"></a><a href="#l16">16</a><td>// under the License.<tr><td><a id="l17"></a><a href="#l17">17</a><td><tr><td><a id="l18"></a><a href="#l18">18</a><td>/**<tr><td><a id="l19"></a><a href="#l19">19</a><td> * @fileoverview Various utilities for working with<tr><td><a id="l20"></a><a href="#l20">20</a><td> * {@link webdriver.CommandExecutor} implementations.<tr><td><a id="l21"></a><a href="#l21">21</a><td> */<tr><td><a id="l22"></a><a href="#l22">22</a><td><tr><td><a id="l23"></a><a href="#l23">23</a><td>var HttpClient = require(&#39;./http&#39;).HttpClient,<tr><td><a id="l24"></a><a href="#l24">24</a><td> HttpExecutor = require(&#39;./http&#39;).Executor,<tr><td><a id="l25"></a><a href="#l25">25</a><td> promise = require(&#39;./_base&#39;).require(&#39;webdriver.promise&#39;);<tr><td><a id="l26"></a><a href="#l26">26</a><td><tr><td><a id="l27"></a><a href="#l27">27</a><td><tr><td><a id="l28"></a><a href="#l28">28</a><td><tr><td><a id="l29"></a><a href="#l29">29</a><td>/**<tr><td><a id="l30"></a><a href="#l30">30</a><td> * Wraps a promised {@link webdriver.CommandExecutor}, ensuring no commands<tr><td><a id="l31"></a><a href="#l31">31</a><td> * are executed until the wrapped executor has been fully built.<tr><td><a id="l32"></a><a href="#l32">32</a><td> * @param {!webdriver.promise.Promise.&lt;!webdriver.CommandExecutor&gt;} delegate The<tr><td><a id="l33"></a><a href="#l33">33</a><td> * promised delegate.<tr><td><a id="l34"></a><a href="#l34">34</a><td> * @constructor<tr><td><a id="l35"></a><a href="#l35">35</a><td> * @implements {webdriver.CommandExecutor}<tr><td><a id="l36"></a><a href="#l36">36</a><td> */<tr><td><a id="l37"></a><a href="#l37">37</a><td>var DeferredExecutor = function(delegate) {<tr><td><a id="l38"></a><a href="#l38">38</a><td><tr><td><a id="l39"></a><a href="#l39">39</a><td> /** @override */<tr><td><a id="l40"></a><a href="#l40">40</a><td> this.execute = function(command, callback) {<tr><td><a id="l41"></a><a href="#l41">41</a><td> delegate.then(function(executor) {<tr><td><a id="l42"></a><a href="#l42">42</a><td> executor.execute(command, callback);<tr><td><a id="l43"></a><a href="#l43">43</a><td> }, callback);<tr><td><a id="l44"></a><a href="#l44">44</a><td> };<tr><td><a id="l45"></a><a href="#l45">45</a><td>};<tr><td><a id="l46"></a><a href="#l46">46</a><td><tr><td><a id="l47"></a><a href="#l47">47</a><td><tr><td><a id="l48"></a><a href="#l48">48</a><td>// PUBLIC API<tr><td><a id="l49"></a><a href="#l49">49</a><td><tr><td><a id="l50"></a><a href="#l50">50</a><td><tr><td><a id="l51"></a><a href="#l51">51</a><td>exports.DeferredExecutor = DeferredExecutor;<tr><td><a id="l52"></a><a href="#l52">52</a><td><tr><td><a id="l53"></a><a href="#l53">53</a><td>/**<tr><td><a id="l54"></a><a href="#l54">54</a><td> * Creates a command executor that uses WebDriver&#39;s JSON wire protocol.<tr><td><a id="l55"></a><a href="#l55">55</a><td> * @param {(string|!webdriver.promise.Promise.&lt;string&gt;)} url The server&#39;s URL,<tr><td><a id="l56"></a><a href="#l56">56</a><td> * or a promise that will resolve to that URL.<tr><td><a id="l57"></a><a href="#l57">57</a><td> * @param {string=} opt_proxy (optional) The URL of the HTTP proxy for the<tr><td><a id="l58"></a><a href="#l58">58</a><td> * client to use.<tr><td><a id="l59"></a><a href="#l59">59</a><td> * @returns {!webdriver.CommandExecutor} The new command executor.<tr><td><a id="l60"></a><a href="#l60">60</a><td> */<tr><td><a id="l61"></a><a href="#l61">61</a><td>exports.createExecutor = function(url, opt_proxy) {<tr><td><a id="l62"></a><a href="#l62">62</a><td> return new DeferredExecutor(promise.when(url, function(url) {<tr><td><a id="l63"></a><a href="#l63">63</a><td> var client = new HttpClient(url, null, opt_proxy);<tr><td><a id="l64"></a><a href="#l64">64</a><td> return new HttpExecutor(client);<tr><td><a id="l65"></a><a href="#l65">65</a><td> }));<tr><td><a id="l66"></a><a href="#l66">66</a><td>};</table></div></article><nav><h3><a href="../index.html" tabindex="2">Overview</a></h3><div><input type="checkbox" id="nav-modules" checked/><label for="nav-modules"><h3><span class="selectable" tabindex="2">Modules</span></h3></label><div id="nav-modules-view"></div></div><div><input type="checkbox" id="nav-types" checked/><label for="nav-types"><h3><span class="selectable" tabindex="2">Types</span></h3></label><div id="nav-types-view"></div></div><h3><a href="../Changes.html" tabindex="2">Changes</a></h3></nav></main><footer><div><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></div></footer><script src="../types.js"></script><script src="../dossier.js"></script>