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

Side by Side Diff: chrome/test/chromedriver/session.cc

Issue 12764021: [chromedriver] Support clicking an element in sub frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/test/chromedriver/session.h" 5 #include "chrome/test/chromedriver/session.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/sys_info.h" 9 #include "base/sys_info.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/test/chromedriver/chrome.h" 11 #include "chrome/test/chromedriver/chrome.h"
12 #include "chrome/test/chromedriver/status.h" 12 #include "chrome/test/chromedriver/status.h"
13 #include "chrome/test/chromedriver/version.h" 13 #include "chrome/test/chromedriver/version.h"
14 #include "chrome/test/chromedriver/web_view.h" 14 #include "chrome/test/chromedriver/web_view.h"
15 15
16 FrameElement::FrameElement(const std::string& parent_frame_id,
17 const std::string& frame_id,
18 const std::string& chromedriver_frame_id)
19 : parent_frame_id(parent_frame_id), frame_id(frame_id),
kkania 2013/03/13 00:06:20 normal style is to put these on separate lines if
chrisgao (Use stgao instead) 2013/03/13 00:36:48 Done.
20 chromedriver_frame_id(chromedriver_frame_id) {}
21
16 Session::Session(const std::string& id) 22 Session::Session(const std::string& id)
17 : id(id), 23 : id(id),
18 mouse_position(0, 0), 24 mouse_position(0, 0),
19 implicit_wait(0), 25 implicit_wait(0),
20 page_load_timeout(0), 26 page_load_timeout(0),
21 script_timeout(0) { 27 script_timeout(0) {
22 } 28 }
23 29
24 Session::Session(const std::string& id, scoped_ptr<Chrome> chrome) 30 Session::Session(const std::string& id, scoped_ptr<Chrome> chrome)
25 : id(id), 31 : id(id),
(...skipping 19 matching lines...) Expand all
45 for (std::list<WebView*>::const_iterator it = web_views.begin(); 51 for (std::list<WebView*>::const_iterator it = web_views.begin();
46 it != web_views.end(); ++it) { 52 it != web_views.end(); ++it) {
47 if ((*it)->GetId() == window) { 53 if ((*it)->GetId() == window) {
48 *web_view = *it; 54 *web_view = *it;
49 return Status(kOk); 55 return Status(kOk);
50 } 56 }
51 } 57 }
52 return Status(kNoSuchWindow, "target window already closed"); 58 return Status(kNoSuchWindow, "target window already closed");
53 } 59 }
54 60
61 void Session::SwitchToTopFrame() {
62 frame_elements.clear();
63 }
64
65 void Session::SwitchToSubFrame(const std::string& frame_id,
66 const std::string& chromedriver_frame_id) {
67 std::string parent_frame_id = "";
kkania 2013/03/13 00:06:20 remove = ""
chrisgao (Use stgao instead) 2013/03/13 00:36:48 Done.
68 if (!frame_elements.empty())
69 parent_frame_id = frame_elements.back().frame_id;
70 frame_elements.push_back(
71 FrameElement(parent_frame_id, frame_id, chromedriver_frame_id));
72 }
73
74 std::string Session::GetCurrentFrameId() const {
75 if (frame_elements.empty())
76 return "";
77 return frame_elements.back().frame_id;
78 }
79
55 scoped_ptr<base::DictionaryValue> Session::CreateCapabilities() { 80 scoped_ptr<base::DictionaryValue> Session::CreateCapabilities() {
56 scoped_ptr<base::DictionaryValue> caps(new base::DictionaryValue()); 81 scoped_ptr<base::DictionaryValue> caps(new base::DictionaryValue());
57 caps->SetString("browserName", "chrome"); 82 caps->SetString("browserName", "chrome");
58 caps->SetString("version", chrome->GetVersion()); 83 caps->SetString("version", chrome->GetVersion());
59 caps->SetString("driverVersion", kChromeDriverVersion); 84 caps->SetString("driverVersion", kChromeDriverVersion);
60 caps->SetString("platform", base::SysInfo::OperatingSystemName()); 85 caps->SetString("platform", base::SysInfo::OperatingSystemName());
61 caps->SetBoolean("javascriptEnabled", true); 86 caps->SetBoolean("javascriptEnabled", true);
62 caps->SetBoolean("takesScreenshot", true); 87 caps->SetBoolean("takesScreenshot", true);
63 caps->SetBoolean("handlesAlerts", true); 88 caps->SetBoolean("handlesAlerts", true);
64 caps->SetBoolean("databaseEnabled", true); 89 caps->SetBoolean("databaseEnabled", true);
(...skipping 10 matching lines...) Expand all
75 100
76 SessionAccessorImpl::SessionAccessorImpl(scoped_ptr<Session> session) 101 SessionAccessorImpl::SessionAccessorImpl(scoped_ptr<Session> session)
77 : session_(session.Pass()) {} 102 : session_(session.Pass()) {}
78 103
79 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) { 104 Session* SessionAccessorImpl::Access(scoped_ptr<base::AutoLock>* lock) {
80 lock->reset(new base::AutoLock(session_lock_)); 105 lock->reset(new base::AutoLock(session_lock_));
81 return session_.get(); 106 return session_.get();
82 } 107 }
83 108
84 SessionAccessorImpl::~SessionAccessorImpl() {} 109 SessionAccessorImpl::~SessionAccessorImpl() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698