Created
September 25, 2019 16:20
-
-
Save jimevans/65bf2a5c4bd7382bd6200df1da4933df to your computer and use it in GitHub Desktop.
use of diagnostics script engine to execute script in IE driver refactor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::wstring script = L""; | |
| //script.append(L"browser.result = browser.executeScript(\""); | |
| //script.append(L"(function() { "); | |
| //script.append(script_source); | |
| //script.append(L" }).apply(window, [])"); | |
| //script.append(L"\");"); | |
| //script.append(L"\nexternal.sendMessage('debug', JSON.stringify(browser.webdriver.known));"); | |
| //script.append(L"\nexternal.sendMessage('script', JSON.stringify(browser.result));"); | |
| //script.append(L"browser.scriptContext = dom.getCrossSiteWindow(browser.document.parentWindow, browser.document.parentWindow);"); | |
| script.append(L"browser.context = browser.executeScript(\"window;\""); | |
| script.append(L"\nexternal.sendMessage('script', JSON.stringify(browser.context.frames.length));"); | |
| HRESULT hr = this->script_engine_->EvaluateScript(script.c_str(), L""); | |
| if (FAILED(hr)) { | |
| _com_error error(hr); | |
| std::wstring formatted_message = | |
| StringUtilities::Format(L"Received error: 0x%08x ['%s']", | |
| hr, | |
| error.ErrorMessage()); | |
| this->response_ = StringUtilities::ToString(formatted_message); | |
| } else { | |
| script = L""; | |
| script.append(L"browser.result = browser.scriptFn.apply(window);"); | |
| //script.append(L"\nexternal.sendMessage('script', JSON.stringify(browser.result));"); | |
| hr = this->script_engine_->EvaluateScript(script.c_str(), L""); | |
| this->response_ = "success"; | |
| } | |
| return; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment