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

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

Issue 7582005: Add chrome.loadAsync capability to ChromeDriver, which allows the user not to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix mac Created 9 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/commands/webdriver_command.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')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_SESSION_H_ 5 #ifndef CHROME_TEST_WEBDRIVER_SESSION_H_
6 #define CHROME_TEST_WEBDRIVER_SESSION_H_ 6 #define CHROME_TEST_WEBDRIVER_SESSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 int window_id; 46 int window_id;
47 FramePath frame_path; 47 FramePath frame_path;
48 }; 48 };
49 49
50 // Every connection made by WebDriver maps to a session object. 50 // Every connection made by WebDriver maps to a session object.
51 // This object creates the chrome instance and keeps track of the 51 // This object creates the chrome instance and keeps track of the
52 // state necessary to control the chrome browser created. 52 // state necessary to control the chrome browser created.
53 // A session manages its own lifetime. 53 // A session manages its own lifetime.
54 class Session { 54 class Session {
55 public: 55 public:
56 struct Options {
57 Options();
58 ~Options();
59
60 // True if the session should simulate OS-level input. Currently only
61 // applies to keyboard input.
62 bool use_native_events;
63
64 // True if the session should not wait for page loads and navigate
65 // asynchronously.
66 bool load_async;
67 };
68
56 // Adds this |Session| to the |SessionManager|. The session manages its own 69 // Adds this |Session| to the |SessionManager|. The session manages its own
57 // lifetime. Do not call delete. 70 // lifetime. Do not call delete.
58 Session(); 71 explicit Session(const Options& options);
72
59 // Removes this |Session| from the |SessionManager|. 73 // Removes this |Session| from the |SessionManager|.
60 ~Session(); 74 ~Session();
61 75
62 // Starts the session thread and a new browser, using the exe found at 76 // Starts the session thread and a new browser, using the exe found at
63 // |browser_exe| and duplicating the provided |user_data_dir|. 77 // |browser_exe| and duplicating the provided |user_data_dir|.
64 // If |browser_exe| is empty, it will search in all the default locations. 78 // If |browser_exe| is empty, it will search in all the default locations.
65 // It |user_data_dir| is empty, it will use a temporary dir. 79 // It |user_data_dir| is empty, it will use a temporary dir.
66 // Returns true on success. On failure, the session will delete 80 // Returns true on success. On failure, the session will delete
67 // itself and return an error code. 81 // itself and return an error code.
68 Error* Init(const FilePath& browser_exe, 82 Error* Init(const FilePath& browser_exe,
69 const FilePath& user_data_dir, 83 const FilePath& user_data_dir,
70 const CommandLine& options); 84 const CommandLine& options);
71 85
86 // Should be called before executing a command. Performs necessary waits
87 // and frame switching.
88 Error* BeforeExecuteCommand();
89
72 // Terminates this session and deletes itself. 90 // Terminates this session and deletes itself.
73 void Terminate(); 91 void Terminate();
74 92
75 // Executes the given |script| in the context of the given frame. 93 // Executes the given |script| in the context of the given frame.
76 // The |script| should be in the form of a function body 94 // The |script| should be in the form of a function body
77 // (e.g. "return arguments[0]"), where |args| is the list of arguments to 95 // (e.g. "return arguments[0]"), where |args| is the list of arguments to
78 // pass to the function. The caller is responsible for the script result 96 // pass to the function. The caller is responsible for the script result
79 // |value|, which is set only if there is no error. 97 // |value|, which is set only if there is no error.
80 Error* ExecuteScript(const FrameId& frame_id, 98 Error* ExecuteScript(const FrameId& frame_id,
81 const std::string& script, 99 const std::string& script,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 const std::string& id() const; 295 const std::string& id() const;
278 296
279 const FrameId& current_target() const; 297 const FrameId& current_target() const;
280 298
281 void set_async_script_timeout(int timeout_ms); 299 void set_async_script_timeout(int timeout_ms);
282 int async_script_timeout() const; 300 int async_script_timeout() const;
283 301
284 void set_implicit_wait(int timeout_ms); 302 void set_implicit_wait(int timeout_ms);
285 int implicit_wait() const; 303 int implicit_wait() const;
286 304
287 void set_screenshot_on_error(bool error); 305 const gfx::Point& get_mouse_position() const;
288 bool screenshot_on_error() const;
289 306
290 void set_use_native_events(bool use_native_events); 307 const Options& options() const;
291 bool use_native_events() const;
292
293 const gfx::Point& get_mouse_position() const;
294 308
295 private: 309 private:
296 void RunSessionTask(Task* task); 310 void RunSessionTask(Task* task);
297 void RunSessionTaskOnSessionThread( 311 void RunSessionTaskOnSessionThread(
298 Task* task, 312 Task* task,
299 base::WaitableEvent* done_event); 313 base::WaitableEvent* done_event);
300 void InitOnSessionThread(const FilePath& browser_exe, 314 void InitOnSessionThread(const FilePath& browser_exe,
301 const FilePath& user_data_dir, 315 const FilePath& user_data_dir,
302 const CommandLine& options, 316 const CommandLine& options,
303 Error** error); 317 Error** error);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 352
339 scoped_ptr<Automation> automation_; 353 scoped_ptr<Automation> automation_;
340 base::Thread thread_; 354 base::Thread thread_;
341 355
342 // Timeout (in ms) for asynchronous script execution. 356 // Timeout (in ms) for asynchronous script execution.
343 int async_script_timeout_; 357 int async_script_timeout_;
344 358
345 // Time (in ms) of how long to wait while searching for a single element. 359 // Time (in ms) of how long to wait while searching for a single element.
346 int implicit_wait_; 360 int implicit_wait_;
347 361
348 // Since screenshots can be very large when in base64 PNG format; the
349 // client is allowed to dyamically enable/disable screenshots on error
350 // during the lifetime of the session.
351 bool screenshot_on_error_;
352
353 // True if the session should simulate OS-level input. Currently only applies
354 // to keyboard input.
355 bool use_native_events_;
356
357 // Vector of the |WebElementId|s for each frame of the current target frame 362 // Vector of the |WebElementId|s for each frame of the current target frame
358 // path. The first refers to the first frame element in the root document. 363 // path. The first refers to the first frame element in the root document.
359 // If the target frame is window.top, this will be empty. 364 // If the target frame is window.top, this will be empty.
360 std::vector<WebElementId> frame_elements_; 365 std::vector<WebElementId> frame_elements_;
361 366
362 // Last mouse position. Advanced APIs need this value. 367 // Last mouse position. Advanced APIs need this value.
363 gfx::Point mouse_position_; 368 gfx::Point mouse_position_;
364 369
365 // Chrome does not have an individual method for setting the prompt text 370 // Chrome does not have an individual method for setting the prompt text
366 // of an alert. Instead, when the WebDriver client wants to set the text, 371 // of an alert. Instead, when the WebDriver client wants to set the text,
367 // we store it here and pass the text when the alert is accepted or 372 // we store it here and pass the text when the alert is accepted or
368 // dismissed. This text should only be used if |has_alert_prompt_text_| 373 // dismissed. This text should only be used if |has_alert_prompt_text_|
369 // is true, so that the default prompt text is not overridden. 374 // is true, so that the default prompt text is not overridden.
370 std::string alert_prompt_text_; 375 std::string alert_prompt_text_;
371 bool has_alert_prompt_text_; 376 bool has_alert_prompt_text_;
372 377
378 Options options_;
379
373 DISALLOW_COPY_AND_ASSIGN(Session); 380 DISALLOW_COPY_AND_ASSIGN(Session);
374 }; 381 };
375 382
376 } // namespace webdriver 383 } // namespace webdriver
377 384
378 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session); 385 DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Session);
379 386
380 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_ 387 #endif // CHROME_TEST_WEBDRIVER_SESSION_H_
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/webdriver_command.cc ('k') | chrome/test/webdriver/session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698