public static void GetUIElement(object sender, EventArgs e, DataTable nativeSearchParameters, IfrmCommandEditor editor) { ChromeExtensionRegistryManager registryManager = new ChromeExtensionRegistryManager(); bool isChromeNativeMessagingInstalled = registryManager.IsExtensionInstalled(); if (isChromeNativeMessagingInstalled) { try { User32Functions.BringChromeWindowToTop(); string webElementStr; NativeRequest.ProcessRequest("getelement", "", 60, out webElementStr); if (!string.IsNullOrEmpty(webElementStr) && webElementStr != "stopped") { if (!webElementStr.Contains("tagName")) { NativeResponse responseObject = JsonConvert.DeserializeObject <NativeResponse>(webElementStr); if (responseObject.Status == "Failed") { throw new Exception(responseObject.Result); } } WebElement webElement = JsonConvert.DeserializeObject <WebElement>(webElementStr); DataTable SearchParameters = WebElementToDataTable(webElement); if (SearchParameters != null) { nativeSearchParameters.Rows.Clear(); foreach (DataRow rw in SearchParameters.Rows) { nativeSearchParameters.ImportRow(rw); } } } } catch (Exception ex) { // Throw Error in Message Box if (ex.Message.Contains("Pipe hasn't been connected yet.")) { var result = ((Form)editor).Invoke(new Action(() => { editor.ShowMessage("Chrome Native Extension is not installed! \n Please visit: https://chrome.google.com/webstore/detail/openbots-web-automation/kkepankimcahnjamnimeijpplgjpmdpp/related", "MessageBox", DialogType.OkOnly, 10); } )); } else if (ex.Message.ToLower().Contains("arithmetic operation resulted in an overflow")) { var result = ((Form)editor).Invoke(new Action(() => { editor.ShowMessage("Chrome Native Extension stopped responding.", "MessageBox", DialogType.OkOnly, 10); } )); } else { var result = ((Form)editor).Invoke(new Action(() => { editor.ShowMessage(ex.Message, "MessageBox", DialogType.OkOnly, 10); } )); } } finally { Process process = Process.GetCurrentProcess(); User32Functions.ActivateWindow(process.MainWindowTitle); } } else { var result = ((Form)editor).Invoke(new Action(() => { editor.ShowMessage("Chrome Native Extension is not installed! \nPlease open the Extensions Manager to install Chrome Native Extension.", "MessageBox", DialogType.OkOnly, 10); } )); } }