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