diff --git a/src/webdriver/extension_qt/qwebkit_proxy.cc b/src/webdriver/extension_qt/qwebkit_proxy.cc index cdc0a03d..576f2a62 100644 --- a/src/webdriver/extension_qt/qwebkit_proxy.cc +++ b/src/webdriver/extension_qt/qwebkit_proxy.cc @@ -24,6 +24,8 @@ #include "frame_path.h" #include "value_conversion_util.h" #include "webdriver_logging.h" +#include "webdriver_server.h" +#include "webdriver_switches.h" #include "third_party/webdriver/atoms.h" @@ -511,6 +513,8 @@ Error* QWebkitProxy::SetActiveElement(const ElementId& element) { Error* QWebkitProxy::SwitchTo() { AddBrowserLoggerToView(); + SetWebInspectorSupport(page_); + // reset frame path session_->frame_elements_.clear(); session_->set_current_frame(FramePath()); @@ -1861,6 +1865,26 @@ void QWebkitProxy::AddBrowserLoggerToView() { logHandler->loadConsoleJS(page_); } +void QWebkitProxy::SetWebInspectorSupport(QWebPage *page) +{ + page->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + CommandLine cmdLine = webdriver::Server::GetInstance()->GetCommandLine(); + + if (cmdLine.HasSwitch(webdriver::Switches::kWIServer)) + { + if (cmdLine.HasSwitch(webdriver::Switches::kWIPort)) + { + std::string wiPort = cmdLine.GetSwitchValueASCII(webdriver::Switches::kWIPort); + int port = QString(wiPort.c_str()).toInt(); + page->setProperty("_q_webInspectorServerPort", port); + } + else + { + page->setProperty("_q_webInspectorServerPort", 9222); + } + } +} + } // namespace webdriver diff --git a/src/webdriver/extension_qt/qwebkit_proxy.h b/src/webdriver/extension_qt/qwebkit_proxy.h index a46a5ab3..ba32c38b 100644 --- a/src/webdriver/extension_qt/qwebkit_proxy.h +++ b/src/webdriver/extension_qt/qwebkit_proxy.h @@ -273,6 +273,7 @@ class QWebkitProxy { base::ListValue* args); void AddBrowserLoggerToView(); + void SetWebInspectorSupport(QWebPage *page); private: