Index: chrome/test/webdriver/session.h |
diff --git a/chrome/test/webdriver/session.h b/chrome/test/webdriver/session.h |
index abd8021d60f38410be62a5213c30aeaa28d68065..5acaa72433221f4effd92ba753e943ab173758c8 100644 |
--- a/chrome/test/webdriver/session.h |
+++ b/chrome/test/webdriver/session.h |
@@ -5,6 +5,7 @@ |
#ifndef CHROME_TEST_WEBDRIVER_SESSION_H_ |
#define CHROME_TEST_WEBDRIVER_SESSION_H_ |
+#include <map> |
#include <string> |
#include "base/scoped_ptr.h" |
@@ -29,21 +30,30 @@ namespace webdriver { |
// http://code.google.com/p/chromium/issues/detail?id=56865 |
class Session { |
public: |
- explicit Session(const std::string& id); |
+ // Adds this |Session| to the |SessionManager|. |
+ Session(); |
+ // Removes this |Session| from the |SessionManager|. |
~Session(); |
- // Creates a browser. |
+ // Starts the session thread and a new browser. Returns true on |
+ // success. On failure, the session will delete itself and return false. |
bool Init(); |
- // Terminates this session and disconnects its automation proxy. After |
- // invoking this method, the Session can safely be deleted. |
+ // Terminates this session and deletes itself. |
void Terminate(); |
- // Executes the given |script| in the context of the frame that is currently |
- // the focus of this session. The |script| should be in the form of a |
- // function body (e.g. "return arguments[0]"), where \args| is the list of |
- // arguments to pass to the function. The caller is responsible for the |
- // script result |value|. |
+ // Executes the given |script| in the context of the given window and frame. |
+ // The |script| should be in the form of a function body |
+ // (e.g. "return arguments[0]"), where |args| is the list of arguments to |
+ // pass to the function. The caller is responsible for the script result |
+ // |value|. |
+ ErrorCode ExecuteScript(int window_id, |
+ const std::string& frame_xpath, |
+ const std::string& script, |
+ const ListValue* const args, |
+ Value** value); |
+ |
+ // Same as above, but uses the currently targeted window and frame. |
ErrorCode ExecuteScript(const std::string& script, |
const ListValue* const args, |
Value** value); |
@@ -59,6 +69,24 @@ class Session { |
bool GetURL(std::string* url); |
bool GetTabTitle(std::string* tab_title); |
+ // Gets all the currently existing window IDs. Returns true on success. |
+ bool GetWindowIds(std::vector<int>* window_ids); |
+ |
+ // Switches the window used by default. |name| is either an ID returned by |
+ // |GetWindowIds| or the name attribute of a DOM window. |
+ ErrorCode SwitchToWindow(const std::string& name); |
+ |
+ // Switches the frame used by default. |name_or_id| is either the name or id |
+ // of a frame element. |
+ ErrorCode SwitchToFrameWithNameOrId(const std::string& name_or_id); |
+ |
+ // Switches the frame used by default. |index| is the zero-based frame index. |
+ ErrorCode SwitchToFrameWithIndex(int index); |
+ |
+ // Closes the current window. If this closes the last window in the session, |
+ // the session will be terminated. Returns true on success. |
+ bool CloseWindow(); |
+ |
inline const std::string& id() const { return id_; } |
inline int implicit_wait() { return implicit_wait_; } |
@@ -80,6 +108,8 @@ class Session { |
current_frame_xpath_ = xpath; |
} |
+ inline int current_window_id() const { return current_window_id_; } |
+ |
private: |
void RunSessionTask(Task* task); |
void RunSessionTaskOnSessionThread( |
@@ -88,13 +118,14 @@ class Session { |
void InitOnSessionThread(bool* success); |
void TerminateOnSessionThread(); |
void SendKeysOnSessionThread(const string16& keys, bool* success); |
- |
- scoped_ptr<Automation> automation_; |
- base::Thread thread_; |
+ ErrorCode SwitchToFrameWithJavaScriptLocatedFrame( |
+ const std::string& script, |
+ ListValue* args); |
const std::string id_; |
- int window_num_; |
+ scoped_ptr<Automation> automation_; |
+ base::Thread thread_; |
int implicit_wait_; |
Speed speed_; |
@@ -106,6 +137,7 @@ class Session { |
// should break into 2 xpaths |
// /html/body/table/tbody/tr/td/iframe & /frameset/frame[1]. |
std::string current_frame_xpath_; |
+ int current_window_id_; |
DISALLOW_COPY_AND_ASSIGN(Session); |
}; |