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_UTIL_H_ 6 #define CHROME_TEST_CHROMEDRIVER_ELEMENT_UTIL_H_ 7 8 #include <string> 9 10 #include "base/memory/scoped_ptr.h" 11 #include "chrome/test/chromedriver/basic_types.h" 12 13 namespace base { 14 class DictionaryValue; 15 class ListValue; 16 class Value; 17 } 18 19 struct Session; 20 class Status; 21 class WebView; 22 23 base::DictionaryValue* CreateElement(const std::string& element_id); 24 25 base::Value* CreateValueFrom(const WebPoint& point); 26 27 // |root_element_id| could be null when no root element is given. 28 Status FindElement( 29 int interval_ms, 30 bool only_one, 31 const std::string* root_element_id, 32 Session* session, 33 WebView* web_view, 34 const base::DictionaryValue& params, 35 scoped_ptr<base::Value>* value); 36 37 Status GetElementAttribute( 38 Session* session, 39 WebView* web_view, 40 const std::string& element_id, 41 const std::string& attribute_name, 42 scoped_ptr<base::Value>* value); 43 44 Status IsElementAttributeEqualToIgnoreCase( 45 Session* session, 46 WebView* web_view, 47 const std::string& element_id, 48 const std::string& attribute_name, 49 const std::string& attribute_value, 50 bool* is_equal); 51 52 Status GetElementClickableLocation( 53 Session* session, 54 WebView* web_view, 55 const std::string& element_id, 56 WebPoint* location); 57 58 Status GetElementEffectiveStyle( 59 Session* session, 60 WebView* web_view, 61 const std::string& element_id, 62 const std::string& property_name, 63 std::string* property_value); 64 65 Status GetElementRegion( 66 Session* session, 67 WebView* web_view, 68 const std::string& element_id, 69 WebRect* rect); 70 71 Status GetElementTagName( 72 Session* session, 73 WebView* web_view, 74 const std::string& element_id, 75 std::string* name); 76 77 Status GetElementSize( 78 Session* session, 79 WebView* web_view, 80 const std::string& element_id, 81 WebSize* size); 82 83 Status IsElementDisplayed( 84 Session* session, 85 WebView* web_view, 86 const std::string& element_id, 87 bool ignore_opacity, 88 bool* is_displayed); 89 90 Status IsElementEnabled( 91 Session* session, 92 WebView* web_view, 93 const std::string& element_id, 94 bool* is_enabled); 95 96 Status IsOptionElementSelected( 97 Session* session, 98 WebView* web_view, 99 const std::string& element_id, 100 bool* is_selected); 101 102 Status IsOptionElementTogglable( 103 Session* session, 104 WebView* web_view, 105 const std::string& element_id, 106 bool* is_togglable); 107 108 Status SetOptionElementSelected( 109 Session* session, 110 WebView* web_view, 111 const std::string& element_id, 112 bool selected); 113 114 Status ToggleOptionElement( 115 Session* session, 116 WebView* web_view, 117 const std::string& element_id); 118 119 Status ScrollElementIntoView( 120 Session* session, 121 WebView* web_view, 122 const std::string& element_id, 123 WebPoint* location); 124 125 // |element_id| refers to the element which is to be scrolled into view. 126 // |clickable_element_id| refers to the element needing clickable verification. 127 // They are usually the same, but can be different. This is useful when an image 128 // uses map/area. The image is scrolled, but check clickable against the area. 129 // If |clickable_element_id| is "", no verification will be performed. 130 Status ScrollElementRegionIntoView( 131 Session* session, 132 WebView* web_view, 133 const std::string& element_id, 134 const WebRect& region, 135 bool center, 136 const std::string& clickable_element_id, 137 WebPoint* location); 138 139 #endif // CHROME_TEST_CHROMEDRIVER_ELEMENT_UTIL_H_ 140