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

Side by Side Diff: chrome/test/pyautolib/pyautolib.h

Issue 3012039: Add ExecuteJavascript() method to PyUITestBase (Closed)
Patch Set: merge to head 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 // This file declares the C++ side of PyAuto, the python interface to 5 // This file declares the C++ side of PyAuto, the python interface to
6 // Chromium automation. It access Chromium's internals using Automation Proxy. 6 // Chromium automation. It access Chromium's internals using Automation Proxy.
7 7
8 #ifndef CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ 8 #ifndef CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_
9 #define CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ 9 #define CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_
10 #pragma once 10 #pragma once
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 bool RemoveBookmark(std::wstring& id); 141 bool RemoveBookmark(std::wstring& id);
142 142
143 // Get a handle to browser window at the given index, or NULL on failure. 143 // Get a handle to browser window at the given index, or NULL on failure.
144 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); 144 scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index);
145 145
146 // Meta-method. Experimental pattern of passing args and response as 146 // Meta-method. Experimental pattern of passing args and response as
147 // JSON dict to avoid future use of the SWIG interface and 147 // JSON dict to avoid future use of the SWIG interface and
148 // automation proxy additions. Returns response as JSON dict. 148 // automation proxy additions. Returns response as JSON dict.
149 std::string _SendJSONRequest(int window_index, std::string& request); 149 std::string _SendJSONRequest(int window_index, std::string& request);
150 150
151 // Execute javascript in a given tab, and return the response. This is
152 // a low-level method intended for use mostly by GetDOMValue(). Note that
153 // any complicated manipulation of the page should be done by something
154 // like WebDriver, not PyAuto.
John Grabowski 2010/08/03 06:42:45 Clarify that the only return value is something se
Dirk Pranke 2010/08/04 21:44:12 Done.
155 std::wstring ExecuteJavascript(const std::wstring& script,
156 int window_index = 0,
157 int tab_index = 0,
158 const std::wstring& frame_xpath = L"");
159
160 // Evaluate a Javascript expression and return the result as a string. This
161 // method is intended largely to read values out of the frame DOM.
162 std::wstring GetDOMValue(const std::wstring& expr,
163 int window_index = 0,
164 int tab_index = 0,
165 const std::wstring& frame_xpath = L"");
166
151 // Resets to the default theme. Returns true on success. 167 // Resets to the default theme. Returns true on success.
152 bool ResetToDefaultTheme(); 168 bool ResetToDefaultTheme();
153 169
154 // Sets a cookie value for a url. Returns true on success. 170 // Sets a cookie value for a url. Returns true on success.
155 bool SetCookie(const GURL& cookie_url, const std::string& value, 171 bool SetCookie(const GURL& cookie_url, const std::string& value,
156 int window_index = 0, int tab_index = 0); 172 int window_index = 0, int tab_index = 0);
157 // Gets a cookie value for the given url. 173 // Gets a cookie value for the given url.
158 std::string GetCookie(const GURL& cookie_url, int window_index = 0, 174 std::string GetCookie(const GURL& cookie_url, int window_index = 0,
159 int tab_index = 0); 175 int tab_index = 0);
160 176
161 private: 177 private:
162 // Enables PostTask to main thread. 178 // Enables PostTask to main thread.
163 // Should be shared across multiple instances of PyUITestBase so that this 179 // Should be shared across multiple instances of PyUITestBase so that this
164 // class is re-entrant and multiple instances can be created. 180 // class is re-entrant and multiple instances can be created.
165 // This is necessary since python's unittest module creates instances of 181 // This is necessary since python's unittest module creates instances of
166 // TestCase at load time itself. 182 // TestCase at load time itself.
167 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); 183 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type);
168 static MessageLoop* message_loop_; 184 static MessageLoop* message_loop_;
169 }; 185 };
170 186
171 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ 187 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698