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_ELEMENT_COMMANDS_H_
      6 #define CHROME_TEST_CHROMEDRIVER_ELEMENT_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 std::string&,
     26     const base::DictionaryValue&,
     27     scoped_ptr<base::Value>*)> ElementCommand;
     28 
     29 // Execute a command on a specific element.
     30 Status ExecuteElementCommand(
     31     const ElementCommand& command,
     32     Session* session,
     33     WebView* web_view,
     34     const base::DictionaryValue& params,
     35     scoped_ptr<base::Value>* value);
     36 
     37 // Search for an element on the page, starting from the given element.
     38 Status ExecuteFindChildElement(
     39     int interval_ms,
     40     Session* session,
     41     WebView* web_view,
     42     const std::string& element_id,
     43     const base::DictionaryValue& params,
     44     scoped_ptr<base::Value>* value);
     45 
     46 // Search for multiple elements on the page, starting from the given element.
     47 Status ExecuteFindChildElements(
     48     int interval_ms,
     49     Session* session,
     50     WebView* web_view,
     51     const std::string& element_id,
     52     const base::DictionaryValue& params,
     53     scoped_ptr<base::Value>* value);
     54 
     55 // Move the mouse to the given element.
     56 Status ExecuteHoverOverElement(
     57     Session* session,
     58     WebView* web_view,
     59     const std::string& element_id,
     60     const base::DictionaryValue& params,
     61     scoped_ptr<base::Value>* value);
     62 
     63 // Click on the element.
     64 Status ExecuteClickElement(
     65     Session* session,
     66     WebView* web_view,
     67     const std::string& element_id,
     68     const base::DictionaryValue& params,
     69     scoped_ptr<base::Value>* value);
     70 
     71 // Touch click on the element.
     72 Status ExecuteTouchSingleTap(
     73     Session* session,
     74     WebView* web_view,
     75     const std::string& element_id,
     76     const base::DictionaryValue& params,
     77     scoped_ptr<base::Value>* value);
     78 
     79 // Clear a TEXTAREA or text INPUT element's value.
     80 Status ExecuteClearElement(
     81     Session* session,
     82     WebView* web_view,
     83     const std::string& element_id,
     84     const base::DictionaryValue& params,
     85     scoped_ptr<base::Value>* value);
     86 
     87 // Send a sequence of key strokes to an element.
     88 Status ExecuteSendKeysToElement(
     89     Session* session,
     90     WebView* web_view,
     91     const std::string& element_id,
     92     const base::DictionaryValue& params,
     93     scoped_ptr<base::Value>* value);
     94 
     95 // Submit a form element.
     96 Status ExecuteSubmitElement(
     97     Session* session,
     98     WebView* web_view,
     99     const std::string& element_id,
    100     const base::DictionaryValue& params,
    101     scoped_ptr<base::Value>* value);
    102 
    103 // Returns the text of a given element.
    104 Status ExecuteGetElementText(
    105     Session* session,
    106     WebView* web_view,
    107     const std::string& element_id,
    108     const base::DictionaryValue& params,
    109     scoped_ptr<base::Value>* value);
    110 
    111 // Returns the value of a given element.
    112 Status ExecuteGetElementValue(
    113     Session* session,
    114     WebView* web_view,
    115     const std::string& element_id,
    116     const base::DictionaryValue& params,
    117     scoped_ptr<base::Value>* value);
    118 
    119 // Returns the lower case tag name of a given element.
    120 Status ExecuteGetElementTagName(
    121     Session* session,
    122     WebView* web_view,
    123     const std::string& element_id,
    124     const base::DictionaryValue& params,
    125     scoped_ptr<base::Value>* value);
    126 
    127 Status ExecuteIsElementSelected(
    128     Session* session,
    129     WebView* web_view,
    130     const std::string& element_id,
    131     const base::DictionaryValue& params,
    132     scoped_ptr<base::Value>* value);
    133 
    134 Status ExecuteIsElementEnabled(
    135     Session* session,
    136     WebView* web_view,
    137     const std::string& element_id,
    138     const base::DictionaryValue& params,
    139     scoped_ptr<base::Value>* value);
    140 
    141 Status ExecuteIsElementDisplayed(
    142     Session* session,
    143     WebView* web_view,
    144     const std::string& element_id,
    145     const base::DictionaryValue& params,
    146     scoped_ptr<base::Value>* value);
    147 
    148 // Returns the location of a given element in page coordinates.
    149 Status ExecuteGetElementLocation(
    150     Session* session,
    151     WebView* web_view,
    152     const std::string& element_id,
    153     const base::DictionaryValue& params,
    154     scoped_ptr<base::Value>* value);
    155 
    156 // Returns the location of a given element in client coordinates, after
    157 // scrolling it into view.
    158 Status ExecuteGetElementLocationOnceScrolledIntoView(
    159     Session* session,
    160     WebView* web_view,
    161     const std::string& element_id,
    162     const base::DictionaryValue& params,
    163     scoped_ptr<base::Value>* value);
    164 
    165 Status ExecuteGetElementSize(
    166     Session* session,
    167     WebView* web_view,
    168     const std::string& element_id,
    169     const base::DictionaryValue& params,
    170     scoped_ptr<base::Value>* value);
    171 
    172 Status ExecuteGetElementAttribute(
    173     Session* session,
    174     WebView* web_view,
    175     const std::string& element_id,
    176     const base::DictionaryValue& params,
    177     scoped_ptr<base::Value>* value);
    178 
    179 // Returns the effective style for a given property of the specified element.
    180 Status ExecuteGetElementValueOfCSSProperty(
    181     Session* session,
    182     WebView* web_view,
    183     const std::string& element_id,
    184     const base::DictionaryValue& params,
    185     scoped_ptr<base::Value>* value);
    186 
    187 // Returns whether the two given elements are equivalent.
    188 Status ExecuteElementEquals(
    189     Session* session,
    190     WebView* web_view,
    191     const std::string& element_id,
    192     const base::DictionaryValue& params,
    193     scoped_ptr<base::Value>* value);
    194 
    195 #endif  // CHROME_TEST_CHROMEDRIVER_ELEMENT_COMMANDS_H_
    196