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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_TEST_WEBDRIVER_FRAME_PATH_H_ 6 #define CHROME_TEST_WEBDRIVER_FRAME_PATH_H_ 7 8 #include <string> 9 #include <vector> 10 11 namespace webdriver { 12 13 // A path identifying a frame within an HTML window. Recognized by Chrome 14 // for identifying a frame of the window to execute JavaScript in. 15 class FramePath { 16 public: 17 // Creates a frame path that refers to the root frame. 18 FramePath(); 19 FramePath(const FramePath& other); 20 explicit FramePath(const std::string& path); 21 ~FramePath(); 22 FramePath& operator=(const FramePath& other); 23 24 bool operator==(const FramePath& other) const; 25 26 // Returns a FramePath appended with the given FramePath. 27 FramePath Append(const FramePath& path) const; 28 29 // Returns a FramePath appended with the given path. 30 FramePath Append(const std::string& path) const; 31 32 // Gets the parent path. 33 FramePath Parent() const; 34 35 // Gets the last path component. 36 FramePath BaseName() const; 37 38 // Gets a vector of all the components of the frame path. 39 void GetComponents(std::vector<std::string>* components) const; 40 41 // Returns whether the path refers to the root frame. 42 bool IsRootFrame() const; 43 44 // Returns whether the path refers to a subframe. 45 bool IsSubframe() const; 46 47 // Returns the identifier's string representation. 48 const std::string& value() const; 49 50 private: 51 // This identifier contains newline-delimited xpath expressions to identify 52 // a subframe multiple level deep. 53 // Example: '//iframe[2]\n/frameset/frame[1]' identifies the first frame in 54 // the root document's second iframe. 55 std::string path_; 56 }; 57 58 } // namespace webdriver 59 60 #endif // CHROME_TEST_WEBDRIVER_FRAME_PATH_H_ 61