| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_SESSION_H_ | 6 #define CHROME_TEST_WEBDRIVER_SESSION_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "chrome/common/automation_constants.h" | 16 #include "chrome/common/automation_constants.h" |
| 17 #include "chrome/test/webdriver/automation.h" | 17 #include "chrome/test/webdriver/automation.h" |
| 18 #include "chrome/test/webdriver/frame_path.h" | 18 #include "chrome/test/webdriver/frame_path.h" |
| 19 #include "chrome/test/webdriver/web_element_id.h" | 19 #include "chrome/test/webdriver/web_element_id.h" |
| 20 #include "ui/gfx/point.h" | 20 #include "ui/gfx/point.h" |
| 21 | 21 |
| 22 class CommandLine; | 22 class CommandLine; |
| 23 class DictionaryValue; | |
| 24 class FilePath; | 23 class FilePath; |
| 25 class GURL; | 24 class GURL; |
| 25 |
| 26 namespace base { |
| 27 class DictionaryValue; |
| 26 class ListValue; | 28 class ListValue; |
| 27 class Value; | 29 class Value; |
| 28 | |
| 29 namespace base { | |
| 30 class WaitableEvent; | 30 class WaitableEvent; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace gfx { | 33 namespace gfx { |
| 34 class Rect; | 34 class Rect; |
| 35 class Size; | 35 class Size; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace webdriver { | 38 namespace webdriver { |
| 39 | 39 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 70 // Terminates this session and deletes itself. | 70 // Terminates this session and deletes itself. |
| 71 void Terminate(); | 71 void Terminate(); |
| 72 | 72 |
| 73 // Executes the given |script| in the context of the given frame. | 73 // Executes the given |script| in the context of the given frame. |
| 74 // The |script| should be in the form of a function body | 74 // The |script| should be in the form of a function body |
| 75 // (e.g. "return arguments[0]"), where |args| is the list of arguments to | 75 // (e.g. "return arguments[0]"), where |args| is the list of arguments to |
| 76 // pass to the function. The caller is responsible for the script result | 76 // pass to the function. The caller is responsible for the script result |
| 77 // |value|, which is set only if there is no error. | 77 // |value|, which is set only if there is no error. |
| 78 Error* ExecuteScript(const FrameId& frame_id, | 78 Error* ExecuteScript(const FrameId& frame_id, |
| 79 const std::string& script, | 79 const std::string& script, |
| 80 const ListValue* const args, | 80 const base::ListValue* const args, |
| 81 Value** value); | 81 base::Value** value); |
| 82 | 82 |
| 83 // Same as above, but uses the currently targeted window and frame. | 83 // Same as above, but uses the currently targeted window and frame. |
| 84 Error* ExecuteScript(const std::string& script, | 84 Error* ExecuteScript(const std::string& script, |
| 85 const ListValue* const args, | 85 const base::ListValue* const args, |
| 86 Value** value); | 86 base::Value** value); |
| 87 | 87 |
| 88 // Executes given |script| in the context of the given frame. | 88 // Executes given |script| in the context of the given frame. |
| 89 // The |script| should be in the form of a function body | 89 // The |script| should be in the form of a function body |
| 90 // (e.g. "return arguments[0]"), where |args| is the list of arguments to | 90 // (e.g. "return arguments[0]"), where |args| is the list of arguments to |
| 91 // pass to the function. The caller is responsible for the script result | 91 // pass to the function. The caller is responsible for the script result |
| 92 // |value|, which is set only if there is no error. | 92 // |value|, which is set only if there is no error. |
| 93 Error* ExecuteAsyncScript(const FrameId& frame_id, | 93 Error* ExecuteAsyncScript(const FrameId& frame_id, |
| 94 const std::string& script, | 94 const std::string& script, |
| 95 const ListValue* const args, | 95 const base::ListValue* const args, |
| 96 Value** value); | 96 base::Value** value); |
| 97 | 97 |
| 98 // Send the given keys to the given element dictionary. This function takes | 98 // Send the given keys to the given element dictionary. This function takes |
| 99 // ownership of |element|. | 99 // ownership of |element|. |
| 100 Error* SendKeys(const WebElementId& element, const string16& keys); | 100 Error* SendKeys(const WebElementId& element, const string16& keys); |
| 101 | 101 |
| 102 // Sets the file paths to the file upload control under the given location. | 102 // Sets the file paths to the file upload control under the given location. |
| 103 Error* DragAndDropFilePaths(const gfx::Point& location, | 103 Error* DragAndDropFilePaths(const gfx::Point& location, |
| 104 const std::vector<FilePath::StringType>& paths); | 104 const std::vector<FilePath::StringType>& paths); |
| 105 | 105 |
| 106 // Clicks the mouse at the given location using the given button. | 106 // Clicks the mouse at the given location using the given button. |
| 107 Error* MouseMoveAndClick(const gfx::Point& location, | 107 Error* MouseMoveAndClick(const gfx::Point& location, |
| 108 automation::MouseButton button); | 108 automation::MouseButton button); |
| 109 Error* MouseMove(const gfx::Point& location); | 109 Error* MouseMove(const gfx::Point& location); |
| 110 Error* MouseDrag(const gfx::Point& start, const gfx::Point& end); | 110 Error* MouseDrag(const gfx::Point& start, const gfx::Point& end); |
| 111 Error* MouseClick(automation::MouseButton button); | 111 Error* MouseClick(automation::MouseButton button); |
| 112 Error* MouseButtonDown(); | 112 Error* MouseButtonDown(); |
| 113 Error* MouseButtonUp(); | 113 Error* MouseButtonUp(); |
| 114 Error* MouseDoubleClick(); | 114 Error* MouseDoubleClick(); |
| 115 | 115 |
| 116 Error* NavigateToURL(const std::string& url); | 116 Error* NavigateToURL(const std::string& url); |
| 117 Error* GoForward(); | 117 Error* GoForward(); |
| 118 Error* GoBack(); | 118 Error* GoBack(); |
| 119 Error* Reload(); | 119 Error* Reload(); |
| 120 Error* GetURL(std::string* url); | 120 Error* GetURL(std::string* url); |
| 121 Error* GetURL(GURL* url); | 121 Error* GetURL(GURL* url); |
| 122 Error* GetTitle(std::string* tab_title); | 122 Error* GetTitle(std::string* tab_title); |
| 123 Error* GetScreenShot(std::string* png); | 123 Error* GetScreenShot(std::string* png); |
| 124 | 124 |
| 125 Error* GetCookies(const std::string& url, ListValue** cookies); | 125 Error* GetCookies(const std::string& url, base::ListValue** cookies); |
| 126 bool GetCookiesDeprecated(const GURL& url, std::string* cookies); | 126 bool GetCookiesDeprecated(const GURL& url, std::string* cookies); |
| 127 bool GetCookieByNameDeprecated(const GURL& url, | 127 bool GetCookieByNameDeprecated(const GURL& url, |
| 128 const std::string& cookie_name, | 128 const std::string& cookie_name, |
| 129 std::string* cookie); | 129 std::string* cookie); |
| 130 Error* DeleteCookie(const std::string& url, const std::string& cookie_name); | 130 Error* DeleteCookie(const std::string& url, const std::string& cookie_name); |
| 131 bool DeleteCookieDeprecated(const GURL& url, const std::string& cookie_name); | 131 bool DeleteCookieDeprecated(const GURL& url, const std::string& cookie_name); |
| 132 Error* SetCookie(const std::string& url, DictionaryValue* cookie_dict); | 132 Error* SetCookie(const std::string& url, base::DictionaryValue* cookie_dict); |
| 133 bool SetCookieDeprecated(const GURL& url, const std::string& cookie); | 133 bool SetCookieDeprecated(const GURL& url, const std::string& cookie); |
| 134 | 134 |
| 135 // Gets all the currently existing window IDs. Returns true on success. | 135 // Gets all the currently existing window IDs. Returns true on success. |
| 136 Error* GetWindowIds(std::vector<int>* window_ids); | 136 Error* GetWindowIds(std::vector<int>* window_ids); |
| 137 | 137 |
| 138 // Switches the window used by default. |name| is either an ID returned by | 138 // Switches the window used by default. |name| is either an ID returned by |
| 139 // |GetWindowIds| or the name attribute of a DOM window. | 139 // |GetWindowIds| or the name attribute of a DOM window. |
| 140 Error* SwitchToWindow(const std::string& name); | 140 Error* SwitchToWindow(const std::string& name); |
| 141 | 141 |
| 142 // Switches the frame used by default. |name_or_id| is either the name or id | 142 // Switches the frame used by default. |name_or_id| is either the name or id |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 // Gets the clickable location of the given element. It will be the center | 262 // Gets the clickable location of the given element. It will be the center |
| 263 // location of the element. If the element is not clickable, or if the | 263 // location of the element. If the element is not clickable, or if the |
| 264 // location cannot be determined, an error will be returned. | 264 // location cannot be determined, an error will be returned. |
| 265 Error* GetClickableLocation(const WebElementId& element, | 265 Error* GetClickableLocation(const WebElementId& element, |
| 266 gfx::Point* location); | 266 gfx::Point* location); |
| 267 | 267 |
| 268 // Gets the attribute of the given element. If there are no errors, the | 268 // Gets the attribute of the given element. If there are no errors, the |
| 269 // function sets |value| and the caller takes ownership. | 269 // function sets |value| and the caller takes ownership. |
| 270 Error* GetAttribute(const WebElementId& element, const std::string& key, | 270 Error* GetAttribute(const WebElementId& element, const std::string& key, |
| 271 Value** value); | 271 base::Value** value); |
| 272 | 272 |
| 273 // Waits for all tabs to stop loading. Returns true on success. | 273 // Waits for all tabs to stop loading. Returns true on success. |
| 274 Error* WaitForAllTabsToStopLoading(); | 274 Error* WaitForAllTabsToStopLoading(); |
| 275 | 275 |
| 276 const std::string& id() const; | 276 const std::string& id() const; |
| 277 | 277 |
| 278 const FrameId& current_target() const; | 278 const FrameId& current_target() const; |
| 279 | 279 |
| 280 void set_async_script_timeout(int timeout_ms); | 280 void set_async_script_timeout(int timeout_ms); |
| 281 int async_script_timeout() const; | 281 int async_script_timeout() const; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 299 void InitOnSessionThread(const FilePath& browser_exe, | 299 void InitOnSessionThread(const FilePath& browser_exe, |
| 300 const CommandLine& options, | 300 const CommandLine& options, |
| 301 Error** error); | 301 Error** error); |
| 302 void TerminateOnSessionThread(); | 302 void TerminateOnSessionThread(); |
| 303 | 303 |
| 304 // Executes the given |script| in the context of the given frame. | 304 // Executes the given |script| in the context of the given frame. |
| 305 // Waits for script to finish and parses the response. | 305 // Waits for script to finish and parses the response. |
| 306 // The caller is responsible for the script result |value|. | 306 // The caller is responsible for the script result |value|. |
| 307 Error* ExecuteScriptAndParseResponse(const FrameId& frame_id, | 307 Error* ExecuteScriptAndParseResponse(const FrameId& frame_id, |
| 308 const std::string& script, | 308 const std::string& script, |
| 309 Value** value); | 309 base::Value** value); |
| 310 | 310 |
| 311 void SendKeysOnSessionThread(const string16& keys, Error** error); | 311 void SendKeysOnSessionThread(const string16& keys, Error** error); |
| 312 Error* SwitchToFrameWithJavaScriptLocatedFrame( | 312 Error* SwitchToFrameWithJavaScriptLocatedFrame( |
| 313 const std::string& script, | 313 const std::string& script, |
| 314 ListValue* args); | 314 base::ListValue* args); |
| 315 Error* FindElementsHelper(const FrameId& frame_id, | 315 Error* FindElementsHelper(const FrameId& frame_id, |
| 316 const WebElementId& root_element, | 316 const WebElementId& root_element, |
| 317 const std::string& locator, | 317 const std::string& locator, |
| 318 const std::string& query, | 318 const std::string& query, |
| 319 bool find_one, | 319 bool find_one, |
| 320 std::vector<WebElementId>* elements); | 320 std::vector<WebElementId>* elements); |
| 321 Error* GetElementRegionInViewHelper( | 321 Error* GetElementRegionInViewHelper( |
| 322 const FrameId& frame_id, | 322 const FrameId& frame_id, |
| 323 const WebElementId& element, | 323 const WebElementId& element, |
| 324 const gfx::Rect& region, | 324 const gfx::Rect& region, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 bool has_alert_prompt_text_; | 363 bool has_alert_prompt_text_; |
| 364 | 364 |
| 365 DISALLOW_COPY_AND_ASSIGN(Session); | 365 DISALLOW_COPY_AND_ASSIGN(Session); |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 } // namespace webdriver | 368 } // namespace webdriver |
| 369 | 369 |
| 370 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); | 370 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); |
| 371 | 371 |
| 372 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ | 372 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ |
| OLD | NEW |