本文整理汇总了C++中LOGHR函数的典型用法代码示例。如果您正苦于以下问题:C++ LOGHR函数的具体用法?C++ LOGHR怎么用?C++ LOGHR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOGHR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGHR
std::wstring BrowserWrapper::GetTitle() {
CComPtr<IDispatch> dispatch;
HRESULT hr = this->browser_->get_Document(&dispatch);
if (FAILED(hr)) {
LOGHR(DEBUG, hr) << "Unable to get document";
return L"";
}
CComPtr<IHTMLDocument2> doc;
hr = dispatch->QueryInterface(&doc);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Have document but cannot cast";
return L"";
}
CComBSTR title;
hr = doc->get_title(&title);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get document title";
return L"";
}
std::wstring title_string = (BSTR)title;
return title_string;
}
示例2: script_variant
bool ScriptWrapper::CreateAnonymousFunction(IDispatch* script_engine, DISPID eval_id, const std::wstring& script, VARIANT* result) {
CComVariant script_variant(script.c_str());
DISPPARAMS parameters = {0};
memset(¶meters, 0, sizeof parameters);
parameters.cArgs = 1;
parameters.rgvarg = &script_variant;
parameters.cNamedArgs = 0;
EXCEPINFO exception;
memset(&exception, 0, sizeof exception);
HRESULT hr = script_engine->Invoke(eval_id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶meters, result, &exception, 0);
if (FAILED(hr)) {
if (DISP_E_EXCEPTION == hr) {
LOGHR(INFO, hr) << "Exception message was: " << _bstr_t(exception.bstrDescription) << ": " << _bstr_t(script_variant);
} else {
LOGHR(DEBUG, hr) << "Failed to compile: " << _bstr_t(script_variant);
}
if (result) {
result->vt = VT_USERDEFINED;
if (exception.bstrDescription != NULL) {
result->bstrVal = ::SysAllocStringByteLen((char*)exception.bstrDescription, ::SysStringByteLen(exception.bstrDescription));
} else {
result->bstrVal = ::SysAllocStringByteLen(NULL, 0);
}
}
return false;
}
return true;
}
示例3: LOG
std::string DocumentHost::GetPageSource() {
LOG(TRACE) << "Entering DocumentHost::GetPageSource";
CComPtr<IHTMLDocument2> doc;
this->GetDocument(&doc);
CComPtr<IHTMLDocument3> doc3;
CComQIPtr<IHTMLDocument3> doc_qi_pointer(doc);
if (doc_qi_pointer) {
doc3 = doc_qi_pointer.Detach();
}
if (!doc3) {
LOG(WARN) << "Unable to get document object, QueryInterface to IHTMLDocument3 failed";
return "";
}
CComPtr<IHTMLElement> document_element;
HRESULT hr = doc3->get_documentElement(&document_element);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get document element from page, call to IHTMLDocument3::get_documentElement failed";
return "";
}
CComBSTR html;
hr = document_element->get_outerHTML(&html);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Have document element but cannot read source, call to IHTMLElement::get_outerHTML failed";
return "";
}
std::string page_source = CW2A(html, CP_UTF8);
return page_source;
}
示例4: LOG
void DocumentHost::SetFocusedFrameToParent() {
LOG(TRACE) << "Entering DocumentHost::SetFocusedFrameToParent";
// Three possible outcomes.
// Outcome 1: Already at top-level browsing context. No-op.
if (this->focused_frame_window_ != NULL) {
CComPtr<IHTMLWindow2> parent_window;
HRESULT hr = this->focused_frame_window_->get_parent(&parent_window);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "IHTMLWindow2::get_parent call failed.";
}
CComPtr<IHTMLWindow2> top_window;
hr = this->focused_frame_window_->get_top(&top_window);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "IHTMLWindow2::get_top call failed.";
}
if (top_window.IsEqualObject(parent_window)) {
// Outcome 2: Focus is on a frame one level deep, making the
// parent the top-level browsing context. Set focused frame
// pointer to NULL.
this->focused_frame_window_ = NULL;
} else {
// Outcome 3: Focus is on a frame more than one level deep.
// Set focused frame pointer to parent frame.
this->focused_frame_window_ = parent_window;
}
}
}
示例5: LOGHR
bool VariantUtilities::GetVariantObjectPropertyValue(IDispatch* variant_object_dispatch,
std::wstring property_name,
VARIANT* property_value) {
LPOLESTR property_name_pointer = reinterpret_cast<LPOLESTR>(const_cast<wchar_t*>(property_name.data()));
DISPID dispid_property;
HRESULT hr = variant_object_dispatch->GetIDsOfNames(IID_NULL,
&property_name_pointer,
1,
LOCALE_USER_DEFAULT,
&dispid_property);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get dispatch ID (dispid) for property "
<< StringUtilities::ToString(property_name);
return false;
}
// get the value of eval result
DISPPARAMS no_args_dispatch_parameters = { 0 };
hr = variant_object_dispatch->Invoke(dispid_property,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET,
&no_args_dispatch_parameters,
property_value,
NULL,
NULL);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get result for property "
<< StringUtilities::ToString(property_name);
return false;
}
return true;
}
示例6: LOG
std::string DocumentHost::GetPageSource() {
LOG(TRACE) << "Entering DocumentHost::GetPageSource";
CComPtr<IHTMLDocument2> doc;
this->GetDocument(&doc);
CComPtr<IHTMLDocument3> doc3;
HRESULT hr = doc->QueryInterface<IHTMLDocument3>(&doc3);
if (FAILED(hr) || !doc3) {
LOG(WARN) << "Unable to get document object, QueryInterface to IHTMLDocument3 failed";
return "";
}
CComPtr<IHTMLElement> document_element;
hr = doc3->get_documentElement(&document_element);
if (FAILED(hr) || !document_element) {
LOGHR(WARN, hr) << "Unable to get document element from page, call to IHTMLDocument3::get_documentElement failed";
return "";
}
CComBSTR html;
hr = document_element->get_outerHTML(&html);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Have document element but cannot read source, call to IHTMLElement::get_outerHTML failed";
return "";
}
std::wstring converted_html = html;
std::string page_source = StringUtilities::ToString(converted_html);
return page_source;
}
示例7: LOG
void Browser::GetDocument(IHTMLDocument2** doc) {
LOG(TRACE) << "Entering Browser::GetDocument";
CComPtr<IHTMLWindow2> window;
if (this->focused_frame_window() == NULL) {
LOG(INFO) << "No child frame focus. Focus is on top-level frame";
CComPtr<IDispatch> dispatch;
HRESULT hr = this->browser_->get_Document(&dispatch);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get document, IWebBrowser2::get_Document call failed";
return;
}
CComPtr<IHTMLDocument2> dispatch_doc;
hr = dispatch->QueryInterface(&dispatch_doc);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Have document but cannot cast, IDispatch::QueryInterface call failed";
return;
}
dispatch_doc->get_parentWindow(&window);
} else {
window = this->focused_frame_window();
}
if (window) {
bool result = this->GetDocumentFromWindow(window, doc);
if (!result) {
LOG(WARN) << "Cannot get document";
}
} else {
LOG(WARN) << "No window is found";
}
}
示例8: LOG
bool Script::CreateAnonymousFunction(VARIANT* result) {
LOG(TRACE) << "Entering Script::CreateAnonymousFunction";
std::wstring function_eval_script = L"window.document.__webdriver_script_fn = ";
function_eval_script.append(this->source_code_.c_str());
CComBSTR code(function_eval_script.c_str());
CComBSTR lang(L"JScript");
CComVariant exec_script_result;
CComPtr<IHTMLWindow2> window;
HRESULT hr = this->script_engine_host_->get_parentWindow(&window);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed";
return false;
}
//LAM: General Access Denied Error ( could be protected mode )
hr = window->execScript(code, lang, &exec_script_result);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to execute code, call to IHTMLWindow2::execScript failed";
LOG(ERROR) << "Unable to execute code, call to IHTMLWindow2::execScript failed";
return false;
}
bool get_result_success = VariantUtilities::GetVariantObjectPropertyValue(
this->script_engine_host_,
L"__webdriver_script_fn",
result);
return get_result_success;
}
示例9: LOG
std::string Browser::GetWindowName() {
LOG(TRACE) << "Entering Browser::GetWindowName";
CComPtr<IDispatch> dispatch;
HRESULT hr = this->browser_->get_Document(&dispatch);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get document, IWebBrowser2::get_Document call failed";
return "";
}
CComQIPtr<IHTMLDocument2> doc(dispatch);
if (!doc) {
LOGHR(WARN, hr) << "Have document but cannot cast, IDispatch::QueryInterface call failed";
return "";
}
CComPtr<IHTMLWindow2> window;
hr = doc->get_parentWindow(&window);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed";
return "";
}
std::string name = "";
CComBSTR window_name;
hr = window->get_name(&window_name);
if (window_name) {
name = CW2A(window_name, CP_UTF8);
} else {
LOG(WARN) << "Unable to get window name, IHTMLWindow2::get_name failed or returned a NULL value";
}
return name;
}
示例10: LOG
void ScreenshotCommandHandler::ExecuteInternal(
const IECommandExecutor& executor,
const ParametersMap& command_parameters,
Response* response) {
LOG(TRACE) << "Entering ScreenshotCommandHandler::ExecuteInternal";
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
response->SetErrorResponse(status_code, "Unable to get browser");
return;
}
bool isSameColour = true;
HRESULT hr;
int i = 0;
int tries = 4;
const bool should_resize_window = executor.enable_full_page_screenshot();
do {
this->ClearImage();
this->image_ = new CImage();
if (should_resize_window) {
hr = this->CaptureFullPage(browser_wrapper);
} else {
hr = this->CaptureViewport(browser_wrapper);
}
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Failed to capture browser image at " << i << " try";
this->ClearImage();
response->SetSuccessResponse("");
return;
}
isSameColour = IsSameColour();
if (isSameColour) {
::Sleep(2000);
LOG(DEBUG) << "Failed to capture non single color browser image at " << i << " try";
}
i++;
} while ((i < tries) && isSameColour);
// now either correct or single color image is got
std::string base64_screenshot = "";
hr = this->GetBase64Data(base64_screenshot);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to transform browser image to Base64 format";
this->ClearImage();
response->SetSuccessResponse("");
return;
}
this->ClearImage();
response->SetSuccessResponse(base64_screenshot);
}
示例11: LOG
std::string Alert::GetDirectUIDialogText() {
LOG(TRACE) << "Entering Alert::GetDirectUIDialogText";
std::string alert_text_value = "";
HWND direct_ui_child_handle = this->GetDirectUIChild();
CComPtr<IAccessible> window_object;
HRESULT hr = ::AccessibleObjectFromWindow(
direct_ui_child_handle,
OBJID_WINDOW,
IID_IAccessible,
reinterpret_cast<void**>(&window_object));
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Failed to get Active Accessibility window object from dialog";
return alert_text_value;
}
// ASSUMPTION: There is an object with the role of "pane" as a child of
// the window object.
CComPtr<IAccessible> pane_object = this->GetChildWithRole(window_object,
ROLE_SYSTEM_PANE,
0);
if (!pane_object) {
LOG(WARN) << "Failed to get Active Accessibility pane child object from window";
return alert_text_value;
}
// ASSUMPTION: The second "static text" accessibility object is the one
// that contains the message.
CComPtr<IAccessible> message_text_object = this->GetChildWithRole(
pane_object,
ROLE_SYSTEM_STATICTEXT,
1);
if (!message_text_object) {
LOG(WARN) << "Failed to get Active Accessibility text child object from pane";
return alert_text_value;
}
CComVariant child_id;
child_id.vt = VT_I4;
child_id.lVal = CHILDID_SELF;
CComBSTR text_bstr;
hr = message_text_object->get_accName(child_id, &text_bstr);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Failed to get accName property from text object";
return alert_text_value;
}
std::wstring text = text_bstr;
alert_text_value = StringUtilities::ToString(text);
return alert_text_value;
}
示例12: LOG
bool Script::CreateAnonymousFunction(VARIANT* result) {
LOG(TRACE) << "Entering Script::CreateAnonymousFunction";
CComBSTR function_eval_script(L"window.document.__webdriver_script_fn = ");
HRESULT hr = function_eval_script.Append(this->source_code_.c_str());
CComBSTR code(function_eval_script);
CComBSTR lang(L"JScript");
CComVariant exec_script_result;
CComPtr<IHTMLWindow2> window;
hr = this->script_engine_host_->get_parentWindow(&window);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed";
return false;
}
hr = window->execScript(code, lang, &exec_script_result);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to execute code, call to IHTMLWindow2::execScript failed";
return false;
}
OLECHAR FAR* function_object_name = L"__webdriver_script_fn";
DISPID dispid_function_object;
hr = this->script_engine_host_->GetIDsOfNames(IID_NULL,
&function_object_name,
1,
LOCALE_USER_DEFAULT,
&dispid_function_object);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get id of name __webdriver_script_fn";
return false;
}
// get the value of eval result
DISPPARAMS no_args_dispatch_parameters = { NULL, NULL, 0, 0 };
hr = this->script_engine_host_->Invoke(dispid_function_object,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET,
&no_args_dispatch_parameters,
result,
NULL,
NULL);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to get value of eval result";
return false;
}
return true;
}
示例13: LOGHR
bool Element::IsAttachedToDom() {
// Verify that the element is still valid by getting the document
// element and calling IHTMLElement::contains() to see if the document
// contains this element.
if (this->element_) {
CComPtr<IHTMLDOMNode2> node;
HRESULT hr = this->element_->QueryInterface<IHTMLDOMNode2>(&node);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to cast element to IHTMLDomNode2";
return false;
}
CComPtr<IDispatch> dispatch_doc;
hr = node->get_ownerDocument(&dispatch_doc);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to locate owning document, call to IHTMLDOMNode2::get_ownerDocument failed";
return false;
}
if (dispatch_doc) {
CComPtr<IHTMLDocument3> doc;
hr = dispatch_doc.QueryInterface<IHTMLDocument3>(&doc);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Found document but it's not the expected type (IHTMLDocument3)";
return false;
}
CComPtr<IHTMLElement> document_element;
hr = doc->get_documentElement(&document_element);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Unable to locate document element, call to IHTMLDocument3::get_documentElement failed";
return false;
}
if (document_element) {
VARIANT_BOOL contains(VARIANT_FALSE);
hr = document_element->contains(this->element_, &contains);
if (FAILED(hr)) {
LOGHR(WARN, hr) << "Call to IHTMLElement::contains failed";
return false;
}
return contains == VARIANT_TRUE;
}
}
}
return false;
}
示例14: LOG
bool BrowserFactory::GetDocumentFromWindowHandle(HWND window_handle,
IHTMLDocument2** document) {
LOG(TRACE) << "Entering BrowserFactory::GetDocumentFromWindowHandle";
if (window_handle != NULL && this->oleacc_instance_handle_) {
LRESULT result;
::SendMessageTimeout(window_handle,
this->html_getobject_msg_,
0L,
0L,
SMTO_ABORTIFHUNG,
1000,
reinterpret_cast<PDWORD_PTR>(&result));
LPFNOBJECTFROMLRESULT object_pointer = reinterpret_cast<LPFNOBJECTFROMLRESULT>(::GetProcAddress(this->oleacc_instance_handle_, "ObjectFromLresult"));
if (object_pointer != NULL) {
HRESULT hr;
hr = (*object_pointer)(result,
IID_IHTMLDocument2,
0,
reinterpret_cast<void**>(document));
if (SUCCEEDED(hr)) {
return true;
} else {
LOGHR(WARN, hr) << "Unable to convert document object pointer to IHTMLDocument2 object via ObjectFromLresult";
}
} else {
LOG(WARN) << "Unable to get address of ObjectFromLresult method from library; GetProcAddress() for ObjectFromLresult returned NULL";
}
} else {
LOG(WARN) << "Window handle is invalid or OLEACC.DLL is not loaded properly";
}
return false;
}
示例15: LOG
IWebBrowser2* BrowserFactory::CreateBrowser() {
LOG(TRACE) << "Entering BrowserFactory::CreateBrowser";
IWebBrowser2* browser = NULL;
DWORD context = CLSCTX_LOCAL_SERVER;
if (this->ie_major_version_ == 7 && this->windows_major_version_ >= 6) {
// ONLY for IE 7 on Windows Vista. XP and below do not have Protected Mode;
// Windows 7 shipped with IE8.
context = context | CLSCTX_ENABLE_CLOAKING;
}
HRESULT hr = ::CoCreateInstance(CLSID_InternetExplorer,
NULL,
context,
IID_IWebBrowser2,
reinterpret_cast<void**>(&browser));
// When IWebBrowser2::Quit() is called, the wrapper process doesn't
// exit right away. When that happens, CoCreateInstance can fail while
// the abandoned iexplore.exe instance is still valid. The "right" way
// to do this would be to call ::EnumProcesses before calling
// CoCreateInstance, finding all of the iexplore.exe processes, waiting
// for one to exit, and then proceed. However, there is no way to tell
// if a process ID belongs to an Internet Explorer instance, particularly
// when a 32-bit process tries to enumerate 64-bit processes on 64-bit
// Windows. So, we'll take the brute force way out, just retrying the call
// to CoCreateInstance until it succeeds (the old iexplore.exe process has
// exited), or we get a different error code. We'll also set a 45-second
// timeout, with 45 seconds being chosen because it's below the default
// 60 second HTTP request timeout of most language bindings.
if (FAILED(hr) && HRESULT_CODE(hr) == ERROR_SHUTDOWN_IS_SCHEDULED) {
LOG(DEBUG) << "CoCreateInstance for IWebBrowser2 failed due to a "
<< "browser process that has not yet fully exited. Retrying "
<< "until the browser process exits and a new instance can "
<< "be successfully created.";
}
clock_t timeout = clock() + (45 * CLOCKS_PER_SEC);
while (FAILED(hr) &&
HRESULT_CODE(hr) == ERROR_SHUTDOWN_IS_SCHEDULED &&
clock() < timeout) {
::Sleep(500);
hr = ::CoCreateInstance(CLSID_InternetExplorer,
NULL,
context,
IID_IWebBrowser2,
reinterpret_cast<void**>(&browser));
}
if (FAILED(hr) && HRESULT_CODE(hr) != ERROR_SHUTDOWN_IS_SCHEDULED) {
// If we hit this branch, the CoCreateInstance failed due to an unexpected
// error, either before we looped, or at some point during the loop. In
// in either case, there's not much else we can do except log the failure.
LOGHR(WARN, hr) << "CoCreateInstance for IWebBrowser2 failed.";
}
if (browser != NULL) {
browser->put_Visible(VARIANT_TRUE);
}
return browser;
}