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

Unified Diff: chrome/test/pyautolib/pyautolib.cc

Issue 3012039: Add ExecuteJavascript() method to PyUITestBase (Closed)
Patch Set: merge to head Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/pyautolib/pyautolib.cc
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index 58ac2dd379557d0c8420fc34c8fa8fcb312a11c9..9d300d0e190bc9e0892d9fdf9fc1a7a7917b0fa9 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -295,6 +295,36 @@ std::string PyUITestBase::_SendJSONRequest(int window_index,
return response;
}
+std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script,
+ int window_index,
+ int tab_index,
+ const std::wstring& frame_xpath) {
+ scoped_refptr<BrowserProxy> browser_proxy =
+ automation()->GetBrowserWindow(window_index);
+ EXPECT_TRUE(browser_proxy.get());
+ std::wstring response;
+ if (!browser_proxy.get())
+ return response;
+ scoped_refptr<TabProxy> tab_proxy =
+ browser_proxy->GetTab(tab_index);
+ EXPECT_TRUE(tab_proxy.get());
+ if (!tab_proxy.get())
+ return response;
+
+ EXPECT_TRUE(tab_proxy->ExecuteAndExtractString(frame_xpath, script,
+ &response));
+ return response;
+}
+
+std::wstring PyUITestBase::GetDOMValue(const std::wstring& expr,
+ int window_index,
+ int tab_index,
+ const std::wstring& frame_xpath) {
+ std::wstring script = std::wstring(L"window.domAutomationController.send(") +
+ expr + std::wstring(L")");
+ return ExecuteJavascript(script, window_index, tab_index, frame_xpath);
+}
+
bool PyUITestBase::ResetToDefaultTheme() {
return automation()->ResetToDefaultTheme();
}

Powered by Google App Engine
This is Rietveld 408576698