Security update for permissions_by_term
[yaffs-website] / vendor / instaclick / php-webdriver / doc / README.md
1 php-webdriver -- A very thin wrapper of WebDriver
2 =================================================
3
4 ##  DESCRIPTION
5
6 This client aims to be as thin as possible, abusing the dynamic nature of PHP to allow almost all API calls to be a direct transformation of what is defined in the WebDriver protocol itself.
7
8 Most clients require you to first read the protocol to see what's possible, then study the client itself to see how to call it.  This hopes to eliminate the latter step, and invites you to rely almost exclusively on https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol
9
10 Each command is just the name of a function call, and each additional path is just another chained function call.  The function parameter is then either an array() if the command takes JSON parameters, or an individual primitive if it takes a URL parameter.
11
12 The function's return value is exactly what is returned from the server as part of the protocol definition.  If an error is returned, the function will throw the appropriate WebDriverException instance.
13
14 ##  GETTING STARTED
15
16 *   All you need as the server for this client is the selenium-server-standalone-#.jar file provided here:  http://www.seleniumhq.org/download/
17
18 *   Download and run that file, replacing # with the current server version.
19
20         java -jar selenium-server-standalone-#.jar
21
22 *   Then when you create a session, be sure to pass the url to where your server is running.
23
24         // This would be the url of the host running the server-standalone.jar
25         $wd_host = 'http://localhost:4444/wd/hub'; // this is the default
26         $web_driver = new WebDriver($wd_host);
27
28         // First param to session() is the 'browserName' (default = 'firefox')
29         // Second param is a JSON object of additional 'desiredCapabilities'
30
31         // POST /session
32         $session = $web_driver->session('firefox');
33
34 * See also [wiki page for launching different browsers](https://github.com/facebook/php-webdriver/wiki/Launching-Browsers).
35
36 ##  SIMPLE EXAMPLES
37
38 ### Note that all of these match the Protocol exactly
39 *   Move to a specific spot on the screen
40
41         // POST /session/:sessionId/moveto
42         $session->moveto(array('xoffset' => 3, 'yoffset' => 300));
43
44 *   Get the current url
45
46         // GET /session/:sessionId/url
47         $session->url();
48
49 *   Change focus to another frame
50
51         // POST /session/:sessionId/frame
52         $session->frame(array('id' => 'some_frame_id'));
53
54 *   Get a list of window handles for all open windows
55
56         // GET /session/:sessionId/window_handles
57         $session->window_handles();
58
59 *   Accept the currently displayed alert dialog
60
61         // POST /session/:sessionId/accept_alert
62         $session->accept_alert();
63
64 *   Change asynchronous script timeout
65
66         // POST /session/:sessionId/timeouts/async_script
67         $session->timeouts()->async_script(array('ms' => 2000));
68
69 *   Doubleclick an element on a touch screen
70
71         // POST session/:sessionId/touch/doubleclick
72         $session->touch()->doubleclick(array('element' => $element->getID())
73
74 *   Check if two elements are equal
75
76         // GET /session/:sessionId/element/:id/equals/:other
77         $element->equals($other_element->getID()))
78
79 *   Get value of a css property on element
80
81         // GET /session/:sessionId/element/:id/css/:propertyName
82         $element->css($property_name)
83
84 ## 'GET', 'POST', or 'DELETE' to the same command examples
85
86 ### When you can do multiple http methods for the same command, call the command directly for the 'GET', and prepend the http method for the 'POST' or 'DELETE'.
87
88 *   Set landscape orientation with 'POST'
89
90         // POST /session/:sessionId/orientation
91         $session->postOrientation(array('orientation' => 'LANDSCAPE'));
92
93 *   Get landscape orientation with normal 'GET'
94
95         // GET /session/:sessionId/orientation
96         $session->orientation();
97
98 *   Set size of window that has $window_handle with 'POST'
99
100         // If excluded, $window_handle defaults to 'current'
101         // POST /session/:sessionId/window/:windowHandle/size
102         $session
103           ->window($window_handle)
104           ->postSize(array('width' => 10, 'height' => 10));
105
106 *   Get current window size with 'GET'
107
108         // GET /session/:sessionId/window/:windowHandle/size
109         $session->window()->size();
110
111 * Send keystrokes to an element with 'POST'
112
113         // POST /session/:sessionId/element/:id/value
114         // getValue() is deprecated; use postValue($json) or value($json)
115         $element->postValue(array("value" => str_split('some text to send to element')));
116
117 ## Some unavoidable exceptions to direct protocol translation.
118
119 *   Opening pages
120
121         // POST /session/:sessionId/url
122         $session->open('http://www.facebook.com');
123
124 *   Dealing with the session
125
126         // DELETE /session/:sessionId
127         $session->close();
128
129         // GET /session/:sessionId
130         $session->capabilities();
131         
132 *   To find elements
133
134         // POST /session/:sessionId/element
135         $element = $session->element($using, $value);
136
137         // POST /session/:sessionId/elements
138         $session->elements($using, $value);
139
140         // POST /session/:sessionId/element/:id/element
141         $element->element($using, $value);
142
143         // POST /session/:sessionId/element/:id/elements
144         $element->elements($using, $value);
145
146 *   To get the active element
147
148         // POST /session/:sessionId/element/active
149         $session->activeElement();
150
151 *   To manipulate cookies
152
153         // GET /session/:sessionId/cookie
154         $session->getAllCookies();
155
156         // POST /session/:sessionId/cookie
157         $session->setCookie($cookie_json);
158
159         // DELETE /session/:sessionId/cookie
160         $session->deleteAllCookies()
161
162         // DELETE /session/:sessionId/cookie/:name
163         $session->deleteCookie($name)
164
165 *   To manipulate windows
166
167         // POST /session/:sessionId/window
168         $session->focusWindow($window_handle);
169
170         // DELETE /session/:sessionId/window
171         $session->deleteWindow();
172
173 ## More esoteric examples
174
175 *   To set curl options (e.g., timeout and proxy settings)
176
177 ```
178 use WebDriver\Service\CurlService;
179 use WebDriver\ServiceFactory;
180
181 class MyCurlService extends CurlService
182 {
183     const PROXY = 'http://proxyHost:8080';
184     const AUTH = 'proxyUser:proxyPassword';
185
186     /**
187      * {@inheritdoc}
188      */
189     public function execute($requestMethod, $url, $parameters = null, $extraOptions = null)
190     {
191         $extraOptions = array_replace(
192             $extraOptions,
193             array(
194                 CURLOPT_CONNECTTIMEOUT => 30,
195                 CURLOPT_TIMEOUT => 300,
196                 CURLOPT_PROXY => self::PROXY,
197                 CURLOPT_PROXYUSERPWD => self::AUTH,
198             )
199         );
200
201         return parent::execute($requestMethod, $url, $parameters, $extraOptions);
202     }
203 }
204
205 ServiceFactory::setServiceClass('service.curl', 'MyCurlService');
206 ```
207
208