Home | History | Annotate | Download | only in chromedriver
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_
      6 #define CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback_forward.h"
     11 #include "base/memory/scoped_ptr.h"
     12 
     13 namespace base {
     14 class DictionaryValue;
     15 class Value;
     16 }
     17 
     18 struct Session;
     19 class Status;
     20 class WebView;
     21 
     22 typedef base::Callback<Status(
     23     Session* session,
     24     WebView* web_view,
     25     const base::DictionaryValue&,
     26     scoped_ptr<base::Value>*)> WindowCommand;
     27 
     28 // Execute a Window Command on the target window.
     29 Status ExecuteWindowCommand(
     30     const WindowCommand& command,
     31     Session* session,
     32     const base::DictionaryValue& params,
     33     scoped_ptr<base::Value>* value);
     34 
     35 // Loads a URL.
     36 Status ExecuteGet(
     37     Session* session,
     38     WebView* web_view,
     39     const base::DictionaryValue& params,
     40     scoped_ptr<base::Value>* value);
     41 
     42 // Evaluates a given synchronous script with arguments.
     43 Status ExecuteExecuteScript(
     44     Session* session,
     45     WebView* web_view,
     46     const base::DictionaryValue& params,
     47     scoped_ptr<base::Value>* value);
     48 
     49 // Evaluates a given asynchronous script with arguments.
     50 Status ExecuteExecuteAsyncScript(
     51     Session* session,
     52     WebView* web_view,
     53     const base::DictionaryValue& params,
     54     scoped_ptr<base::Value>* value);
     55 
     56 // Changes the targeted frame for the given session.
     57 Status ExecuteSwitchToFrame(
     58     Session* session,
     59     WebView* web_view,
     60     const base::DictionaryValue& params,
     61     scoped_ptr<base::Value>* value);
     62 
     63 // Get the current page title.
     64 Status ExecuteGetTitle(
     65     Session* session,
     66     WebView* web_view,
     67     const base::DictionaryValue& params,
     68     scoped_ptr<base::Value>* value);
     69 
     70 // Get the current page source.
     71 Status ExecuteGetPageSource(
     72     Session* session,
     73     WebView* web_view,
     74     const base::DictionaryValue& params,
     75     scoped_ptr<base::Value>* value);
     76 
     77 // Search for an element on the page, starting from the document root.
     78 Status ExecuteFindElement(
     79     int interval_ms,
     80     Session* session,
     81     WebView* web_view,
     82     const base::DictionaryValue& params,
     83     scoped_ptr<base::Value>* value);
     84 
     85 // Search for multiple elements on the page, starting from the document root.
     86 Status ExecuteFindElements(
     87     int interval_ms,
     88     Session* session,
     89     WebView* web_view,
     90     const base::DictionaryValue& params,
     91     scoped_ptr<base::Value>* value);
     92 
     93 // Get the current page url.
     94 Status ExecuteGetCurrentUrl(
     95     Session* session,
     96     WebView* web_view,
     97     const base::DictionaryValue& params,
     98     scoped_ptr<base::Value>* value);
     99 
    100 // Navigate backward in the browser history.
    101 Status ExecuteGoBack(
    102     Session* session,
    103     WebView* web_view,
    104     const base::DictionaryValue& params,
    105     scoped_ptr<base::Value>* value);
    106 
    107 // Navigate forward in the browser history.
    108 Status ExecuteGoForward(
    109     Session* session,
    110     WebView* web_view,
    111     const base::DictionaryValue& params,
    112     scoped_ptr<base::Value>* value);
    113 
    114 // Refresh the current page.
    115 Status ExecuteRefresh(
    116     Session* session,
    117     WebView* web_view,
    118     const base::DictionaryValue& params,
    119     scoped_ptr<base::Value>* value);
    120 
    121 // Move the mouse by an offset of the element if specified .
    122 Status ExecuteMouseMoveTo(
    123     Session* session,
    124     WebView* web_view,
    125     const base::DictionaryValue& params,
    126     scoped_ptr<base::Value>* value);
    127 
    128 // Click a mouse button at the coordinates set by the last moveto.
    129 Status ExecuteMouseClick(
    130     Session* session,
    131     WebView* web_view,
    132     const base::DictionaryValue& params,
    133     scoped_ptr<base::Value>* value);
    134 
    135 // Click and hold a mouse button at the coordinates set by the last moveto.
    136 Status ExecuteMouseButtonDown(
    137     Session* session,
    138     WebView* web_view,
    139     const base::DictionaryValue& params,
    140     scoped_ptr<base::Value>* value);
    141 
    142 // Releases the mouse button previously held (where the mouse is currently at).
    143 Status ExecuteMouseButtonUp(
    144     Session* session,
    145     WebView* web_view,
    146     const base::DictionaryValue& params,
    147     scoped_ptr<base::Value>* value);
    148 
    149 // Double-clicks at the current mouse coordinates (set by last moveto).
    150 Status ExecuteMouseDoubleClick(
    151     Session* session,
    152     WebView* web_view,
    153     const base::DictionaryValue& params,
    154     scoped_ptr<base::Value>* value);
    155 
    156 // Touch press at a given coordinate.
    157 Status ExecuteTouchDown(
    158     Session* session,
    159     WebView* web_view,
    160     const base::DictionaryValue& params,
    161     scoped_ptr<base::Value>* value);
    162 
    163 // Touch release at a given coordinate.
    164 Status ExecuteTouchUp(
    165     Session* session,
    166     WebView* web_view,
    167     const base::DictionaryValue& params,
    168     scoped_ptr<base::Value>* value);
    169 
    170 // Touch move at a given coordinate.
    171 Status ExecuteTouchMove(
    172     Session* session,
    173     WebView* web_view,
    174     const base::DictionaryValue& params,
    175     scoped_ptr<base::Value>* value);
    176 
    177 Status ExecuteGetActiveElement(
    178     Session* session,
    179     WebView* web_view,
    180     const base::DictionaryValue& params,
    181     scoped_ptr<base::Value>* value);
    182 
    183 // Send a sequence of key strokes to the active element.
    184 Status ExecuteSendKeysToActiveElement(
    185     Session* session,
    186     WebView* web_view,
    187     const base::DictionaryValue& params,
    188     scoped_ptr<base::Value>* value);
    189 
    190 // Gets the status of the application cache (window.applicationCache.status).
    191 Status ExecuteGetAppCacheStatus(
    192     Session* session,
    193     WebView* web_view,
    194     const base::DictionaryValue& params,
    195     scoped_ptr<base::Value>* value);
    196 
    197 Status ExecuteIsBrowserOnline(
    198     Session* session,
    199     WebView* web_view,
    200     const base::DictionaryValue& params,
    201     scoped_ptr<base::Value>* value);
    202 
    203 Status ExecuteGetStorageItem(
    204     const char* storage,
    205     Session* session,
    206     WebView* web_view,
    207     const base::DictionaryValue& params,
    208     scoped_ptr<base::Value>* value);
    209 
    210 Status ExecuteGetStorageKeys(
    211     const char* storage,
    212     Session* session,
    213     WebView* web_view,
    214     const base::DictionaryValue& params,
    215     scoped_ptr<base::Value>* value);
    216 
    217 Status ExecuteSetStorageItem(
    218     const char* storage,
    219     Session* session,
    220     WebView* web_view,
    221     const base::DictionaryValue& params,
    222     scoped_ptr<base::Value>* value);
    223 
    224 Status ExecuteRemoveStorageItem(
    225     const char* storage,
    226     Session* session,
    227     WebView* web_view,
    228     const base::DictionaryValue& params,
    229     scoped_ptr<base::Value>* value);
    230 
    231 Status ExecuteClearStorage(
    232     const char* storage,
    233     Session* session,
    234     WebView* web_view,
    235     const base::DictionaryValue& params,
    236     scoped_ptr<base::Value>* value);
    237 
    238 Status ExecuteGetStorageSize(
    239     const char* storage,
    240     Session* session,
    241     WebView* web_view,
    242     const base::DictionaryValue& params,
    243     scoped_ptr<base::Value>* value);
    244 
    245 Status ExecuteScreenshot(
    246     Session* session,
    247     WebView* web_view,
    248     const base::DictionaryValue& params,
    249     scoped_ptr<base::Value>* value);
    250 
    251 // Retrieve all cookies visible to the current page.
    252 Status ExecuteGetCookies(
    253     Session* session,
    254     WebView* web_view,
    255     const base::DictionaryValue& params,
    256     scoped_ptr<base::Value>* value);
    257 
    258 // Set a cookie. If the cookie path is not specified, it should be set to "/".
    259 // If the domain is omitted, it should default to the current page's domain.
    260 Status ExecuteAddCookie(
    261     Session* session,
    262     WebView* web_view,
    263     const base::DictionaryValue& params,
    264     scoped_ptr<base::Value>* value);
    265 
    266 // Delete the cookie with the given name if it exists in the current page.
    267 Status ExecuteDeleteCookie(
    268     Session* session,
    269     WebView* web_view,
    270     const base::DictionaryValue& params,
    271     scoped_ptr<base::Value>* value);
    272 
    273 // Delete all cookies visible to the current page.
    274 Status ExecuteDeleteAllCookies(
    275     Session* session,
    276     WebView* web_view,
    277     const base::DictionaryValue& params,
    278     scoped_ptr<base::Value>* value);
    279 
    280 Status ExecuteSetLocation(
    281     Session* session,
    282     WebView* web_view,
    283     const base::DictionaryValue& params,
    284     scoped_ptr<base::Value>* value);
    285 
    286 Status ExecuteTakeHeapSnapshot(
    287     Session* session,
    288     WebView* web_view,
    289     const base::DictionaryValue& params,
    290     scoped_ptr<base::Value>* value);
    291 
    292 #endif  // CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_
    293