public void Execute(Arguments arguments) { if (IEManager.SwitchIE(arguments.Id.Value) == false) { throw new InvalidOperationException($"Internet Instance with specified Id: '{arguments.Id.Value}' could not be found."); } }
internal void ActivateTab(string by, string phrase) { TabSearchBy searchBy; if (Enum.TryParse(by.CapitalizeFirstLetter(), out searchBy) == false) { throw new ApplicationException("Argument 'by' is not correct"); } int tabIndexToActivate = 0; switch (searchBy) { case TabSearchBy.Title: tabIndexToActivate = GetTabIndexToActivateByTitle(phrase); break; case TabSearchBy.Url: tabIndexToActivate = GetTabIndexToActivateByUrl(phrase); break; } AccessibleObjectFromWindow(GetDirectUIHWND(_hWnd), OBJID.OBJID_WINDOW, ref _accessible); CheckForAccessible(); var index = 0; var ieDirectUIHWND = new TabActivator(_hWnd); foreach (var accessor in ieDirectUIHWND.Children) { foreach (var child in accessor.Children) { foreach (var tab in child.Children) { if (tabIndexToActivate >= child.ChildCount - 1) { return; } if (index == tabIndexToActivate) { tab.ActivateTab(); var activeIe = IEManager.launchedIE?.Where(ie => ie.Ie.hWnd == _hWnd).FirstOrDefault(); if (activeIe != null) { IEManager.SwitchIE(activeIe.Id); } return; } index++; } } } }
public void Execute(Arguments arguments) { try { IEManager.Detach(IEManager.CurrentIE); } catch (Exception ex) { throw new ApplicationException($"Problem occured while detaching Internet Explorer instance. Message: {ex.Message}", ex); } }
public void Execute(Arguments arguments) { try { IEManager.Close(); } catch (Exception ex) { throw new ApplicationException($"Exception occured while closing Internet Explorer instance. Message: {ex.Message}", ex); } }
public void Execute(Arguments arguments) { try { var wrapper = IEManager.AttachToExistingIE(arguments.Phrase.Value, arguments.By.Value); OnScriptEnd = () => { IEManager.Detach(wrapper); }; Scripter.Variables.SetVariableValue(arguments.Result.Value, new IntegerStructure(wrapper.Id)); wrapper.ActivateTab(arguments.By.Value, arguments.Phrase.Value); } catch (Exception ex) { throw new ArgumentException($"Failed while trying to attach to existing Internet Explorer instance. Please, make sure Internet Explorer instance is running and that the specified searching phrase is correct. Additional message: {ex.Message}"); } }
private IEWrapper CreateIeInstance(bool closeError) { try { IEWrapper wrapper = IEManager.AddIE(); wrapper.Ie = new WatiN.Core.IE(); if (closeError) { OnScriptEnd = () => { IEManager.Detach(wrapper); }; } return(wrapper); } catch (Exception ex) { throw new ApplicationException($"Error occured while trying to create new Internet Explorer instance. Additional message: {ex.Message}", ex); } }