| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_COMMANDS_WEBELEMENT_COMMAND_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMAND_H_ | 6 #define CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/test/webdriver/commands/webdriver_command.h" | 11 #include "chrome/test/webdriver/commands/webdriver_command.h" |
| 12 | 12 |
| 13 class DictionaryValue; |
| 14 |
| 13 namespace webdriver { | 15 namespace webdriver { |
| 14 | 16 |
| 17 class Response; |
| 18 |
| 15 // Handles commands that interact with a web element in the WebDriver REST | 19 // Handles commands that interact with a web element in the WebDriver REST |
| 16 // service. | 20 // service. |
| 17 class WebElementCommand : public WebDriverCommand { | 21 class WebElementCommand : public WebDriverCommand { |
| 18 public: | 22 public: |
| 19 inline WebElementCommand(const std::vector<std::string>& path_segments, | 23 inline WebElementCommand(const std::vector<std::string>& path_segments, |
| 20 const DictionaryValue* const parameters) | 24 const DictionaryValue* const parameters) |
| 21 : WebDriverCommand(path_segments, parameters), | 25 : WebDriverCommand(path_segments, parameters), |
| 22 path_segments_(path_segments) {} | 26 path_segments_(path_segments) {} |
| 23 virtual ~WebElementCommand() {} | 27 virtual ~WebElementCommand() {} |
| 24 | 28 |
| 25 virtual bool Init(Response* const response); | 29 virtual bool Init(Response* const response); |
| 26 | 30 |
| 27 protected: | 31 protected: |
| 28 bool GetElementLocation(bool in_view, int* x, int* y); | 32 bool GetElementLocation(bool in_view, int* x, int* y); |
| 29 bool GetElementSize(int* width, int* height); | 33 bool GetElementSize(int* width, int* height); |
| 30 | 34 |
| 31 const std::vector<std::string>& path_segments_; | 35 const std::vector<std::string>& path_segments_; |
| 32 std::string element_id; | 36 std::string element_id; |
| 33 | 37 |
| 34 private: | 38 private: |
| 35 virtual bool RequiresValidTab() { return true; } | 39 virtual bool RequiresValidTab() { return true; } |
| 36 | 40 |
| 37 DISALLOW_COPY_AND_ASSIGN(WebElementCommand); | 41 DISALLOW_COPY_AND_ASSIGN(WebElementCommand); |
| 38 }; | 42 }; |
| 39 | 43 |
| 44 // Sends keys to the specified web element. Also gets the value property of an |
| 45 // element. |
| 46 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/value |
| 47 class ElementValueCommand : public WebElementCommand { |
| 48 public: |
| 49 ElementValueCommand(const std::vector<std::string>& path_segments, |
| 50 DictionaryValue* parameters) |
| 51 : WebElementCommand(path_segments, parameters) {} |
| 52 virtual ~ElementValueCommand() {} |
| 53 |
| 54 virtual bool DoesGet() { return true; } |
| 55 virtual bool DoesPost() { return true; } |
| 56 virtual void ExecuteGet(Response* const response); |
| 57 virtual void ExecutePost(Response* const response); |
| 58 |
| 59 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(ElementValueCommand); |
| 61 }; |
| 62 |
| 63 // Gets the visible text of the specified web element. |
| 64 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/e
lement/:id/text |
| 65 class ElementTextCommand : public WebElementCommand { |
| 66 public: |
| 67 ElementTextCommand(const std::vector<std::string>& path_segments, |
| 68 DictionaryValue* parameters) |
| 69 : WebElementCommand(path_segments, parameters) {} |
| 70 virtual ~ElementTextCommand() {} |
| 71 |
| 72 virtual bool DoesGet() { return true; } |
| 73 virtual void ExecuteGet(Response* const response); |
| 74 |
| 75 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(ElementTextCommand); |
| 77 }; |
| 78 |
| 40 } // namespace webdriver | 79 } // namespace webdriver |
| 41 | 80 |
| 42 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMAND_H_ | 81 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_WEBELEMENT_COMMANDS_H_ |
| OLD | NEW |