Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/test/webdriver/session.h

Issue 3064012: Base implementation of WebDriver for Chrome. This checkin includes... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/server.cc ('k') | chrome/test/webdriver/session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_H_
6 #define CHROME_TEST_WEBDRIVER_SESSION_H_
7
8 #include <string>
9
10 #include "base/scoped_ptr.h"
11
12 #include "chrome/test/automation/automation_proxy.h"
13 #include "chrome/test/automation/browser_proxy.h"
14 #include "chrome/test/automation/tab_proxy.h"
15 #include "chrome/test/automation/window_proxy.h"
16 #include "chrome/test/webdriver/error_codes.h"
17
18 namespace webdriver {
19
20 // Every connection made by WebDriver maps to a session object.
21 // This object creates the chrome instance and keeps track of the
22 // state necessary to control the chrome browser created.
23 class Session {
24 public:
25 #if defined(OS_POSIX)
26 typedef char ProfileDir[L_tmpnam + 1]; // +1 for \0
27 #elif defined(OS_WIN)
28 typedef char ProfileDir[MAX_PATH + 1]; // +1 for \0
29 #endif
30
31 Session(const std::string& id, AutomationProxy* proxy);
32
33 bool Init(base::ProcessHandle process_handle);
34 bool CreateTemporaryProfileDirectory();
35
36 // Terminates this session and disconnects its automation proxy. After
37 // invoking this method, the Session can safely be deleted.
38 void Terminate();
39
40 scoped_refptr<WindowProxy> GetWindow();
41 scoped_refptr<TabProxy> ActivateTab();
42
43 void SetBrowserAndTab(const int window_num,
44 const scoped_refptr<BrowserProxy>& browser,
45 const scoped_refptr<TabProxy>& tab);
46
47 // Executes the given |script| in the context of the frame that is currently
48 // the focus of this session. The |script| should be in the form of a
49 // function body (e.g. "return arguments[0]"), where \args| is the list of
50 // arguments to pass to the function. The caller is responsible for the
51 // script result |value|.
52 ErrorCode ExecuteScript(const std::wstring& script,
53 const ListValue* const args,
54 Value** value);
55
56 inline const std::string& id() const { return id_; }
57 inline AutomationProxy* proxy() { return proxy_.get(); }
58
59 inline int window_num() const { return window_num_; }
60 inline int implicit_wait() { return implicit_wait_; }
61 inline void set_implicit_wait(const int& timeout) {
62 implicit_wait_ = timeout > 0 ? timeout : 0;
63 }
64
65 inline const char* tmp_profile_dir() {
66 return tmp_profile_dir_;
67 };
68
69 inline const std::wstring& current_frame_xpath() const {
70 return current_frame_xpath_;
71 }
72
73 inline void set_current_frame_xpath(const std::wstring& xpath) {
74 current_frame_xpath_ = xpath;
75 }
76
77 private:
78 bool LoadProxies();
79 bool WaitForLaunch();
80 const std::string id_;
81 const scoped_ptr<AutomationProxy> proxy_;
82
83 // The chrome process that was started for this session.
84 base::Process process_;
85
86 int window_num_;
87 scoped_refptr<BrowserProxy> browser_;
88 scoped_refptr<TabProxy> tab_;
89
90 int implicit_wait_;
91 ProfileDir tmp_profile_dir_;
92
93 // The XPath to the frame within this session's active tab which all
94 // commands should be directed to. XPath strings can represent a frame deep
95 // down the tree (across multiple frame DOMs).
96 // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[1]
97 // should break into 2 xpaths
98 // /html/body/table/tbody/tr/td/iframe & /frameset/frame[1]
99 std::wstring current_frame_xpath_;
100
101 DISALLOW_COPY_AND_ASSIGN(Session);
102 };
103 } // namespace webdriver
104 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_
105
OLDNEW
« no previous file with comments | « chrome/test/webdriver/server.cc ('k') | chrome/test/webdriver/session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698