1 | /*!
|
2 | *
|
3 | * Copyright (c) 2013 Sebastian Golasch
|
4 | *
|
5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
6 | * copy of this software and associated documentation files (the "Software"),
|
7 | * to deal in the Software without restriction, including without limitation
|
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 | * and/or sell copies of the Software, and to permit persons to whom the
|
10 | * Software is furnished to do so, subject to the following conditions:
|
11 | *
|
12 | * The above copyright notice and this permission notice shall be included
|
13 | * in all copies or substantial portions of the Software.
|
14 | *
|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
21 | * DEALINGS IN THE SOFTWARE.
|
22 | *
|
23 | */
|
24 |
|
25 | /**
|
26 | * Cookie related Webdriver endpoints
|
27 | *
|
28 | * @param {Dalek.Internal.Webdriver} Driver Webdriver client instance
|
29 | * @return {Dalek.Internal.Webdriver} Driver Webdriver client instance
|
30 | */
|
31 |
|
32 | module.exports = function (Driver) {
|
33 | ;
|
34 |
|
35 | /**
|
36 | * Retrieve all cookies visible to the current page.
|
37 | *
|
38 | * @method getCookies
|
39 | * @see https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/cookie
|
40 | * @param {GET} sessionId ID of the session to route the command to
|
41 | */
|
42 |
|
43 | Driver.addCommand({
|
44 | name: 'getCookies',
|
45 | url: '/session/:sessionId/cookie',
|
46 | method: 'GET'
|
47 | });
|
48 |
|
49 | /**
|
50 | * Retrieve a cookies by its name.
|
51 | *
|
52 | * @method getCookie
|
53 | * @see https://code.google.com/p/selenium/wiki/JsonWireProtocol#GET_/session/:sessionId/cookie/:name
|
54 | * @param {GET} sessionId ID of the session to route the command to
|
55 | * @param {GET} name Name of the cookie
|
56 | */
|
57 |
|
58 | Driver.addCommand({
|
59 | name: 'getCookie',
|
60 | url: '/session/:sessionId/cookie',
|
61 | method: 'GET'
|
62 | });
|
63 |
|
64 | /**
|
65 | * Set a cookie.
|
66 | * If the cookie path is not specified, it should be set to "/".
|
67 | * Likewise, if the domain is omitted,
|
68 | * it should default to the current page's domain.
|
69 | *
|
70 | * @method setCookie
|
71 | * @see https://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/cookie
|
72 | * @param {GET} sessionId ID of the session to route the command to
|
73 | * @param {POST} cookie The cookie object
|
74 | */
|
75 |
|
76 | Driver.addCommand({
|
77 | name: 'setCookie',
|
78 | url: '/session/:sessionId/cookie',
|
79 | method: 'POST',
|
80 | params: ['cookie']
|
81 | });
|
82 |
|
83 | return Driver;
|
84 | };
|