public static API_GitHub unInstall_TortoiseGit(this API_GitHub gitHub, string msiPath) { var process = msiPath.startProcess(); var guiAutomation = new API_GuiAutomation(process); //step 1 var tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.button("Next >").mouse().click(); //step 2 tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.button("Remove Installation").mouse().click(); //step 3 tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.button("Remove").mouse().click(); //step 4 for (int i = 0; i < 10; i++) { gitHub.sleep(2000, true); // wait 2 secs and try again tortoiseGitSetup = guiAutomation.windows()[0]; if (tortoiseGitSetup.button("Next >").isNull()) { tortoiseGitSetup.button("Finish").mouse().click(); break; } } return(gitHub); }
public bool install() { if (this.isInstalled().isFalse()) { "[API_Fiddler] Starting Fiddler installation process".info(); var fiddlerInstaller = this.installerFile(); var guiAutomation = new API_GuiAutomation(); guiAutomation.launch(fiddlerInstaller); var installWindow = guiAutomation.window("Fiddler2 Setup: License Agreement"); installWindow.button("I Agree").click(); var installTextBox = installWindow.textBox(@"C:\Program Files\Fiddler2"); installTextBox.set_Text(this.Install_Dir); if (installTextBox.get_Text() == this.Install_Dir) { installWindow.button("Install").click(); } else { "[API_Fiddler] in install automation, rrror setting the target directory".error(); } installWindow.button("Close").click(); "[API_Fiddler] Fiddler installation complete".info(); } if (this.isInstalled()) { "[API_Fiddler] Fiddler is installed in folder:{0}".info(this.Install_Dir); return(true); } "[API_Fiddler] Counld NOT find Fiddler installation in folder:{0}".info(this.Install_Dir); return(false); }
public API_GuiAutomation setGuiAutomation() { "Mapping GuiAutomation Objects".info(); //var localProcess = Processes.getCurrentProcess(); //guiAutomation = new API_GuiAutomation(localProcess); var ieProcess = Processes.getProcesses() .Where((process) => process.MainWindowTitle.contains("SI Question Pool")) .First(); guiAutomation = new API_GuiAutomation(ieProcess); if (guiAutomation.notNull()) { "got GuiAutomation Object for local Process".info(); } guiAutomationWindow = guiAutomation.windows()[0]; if (guiAutomationWindow.notNull()) { "got GuiAutomation Window Object for local Process".info(); } else { "failed to get GuiAutomation Window Object for local Process".error(); } //setGuiAutomationExamGroupBox(); //if (guiAutomation.isNull() || guiAutomationWindow.isNull() || guiAutomationExamGroupBox.isNull()); // "in setGuiAutomation, one of the expected UIAutomation objects could not be calculated".error(); return(guiAutomation); }
public API_Fiddler start() { install(); if (Fiddler_Process.notNull()) { "[API_Fiddler] in start, the Fiddler_Process is already mapped to a running process. Stopping request".error(); return(this); } attach(); if (Fiddler_Process.isNull()) // means we were NOT able find a running instance and get its process object { if (Fiddler_Exe.fileExists().isFalse()) { "[API_Fiddler] Could not find Fiddler Exe file at location: {0}".error(Fiddler_Exe); return(null); } Fiddler_Process = Processes.startProcess(Fiddler_Exe); } Fiddler_GuiAutomation = new API_GuiAutomation(Fiddler_Process); if (Fiddler_GuiAutomation.isNull()) { "[API_Fiddler] Could not set Fiddler_GuiAutomation".error(); return(null); } Fiddler_Window = Fiddler_GuiAutomation.window(FIDDLER_MAIN_WINDOW_TITLE); if (Fiddler_Window.isNull()) { "[API_Fiddler] Could not get Fiddler main window with title: {0}".error(FIDDLER_MAIN_WINDOW_TITLE); return(null); } return(this); }
public static API_GuiAutomation_NativeMethods.Rect windowRectangle(this API_GuiAutomation guiAutomation, int windowHandle) { var rect = new API_GuiAutomation_NativeMethods.Rect(); API_GuiAutomation_NativeMethods.GetWindowRect(windowHandle, out rect); return(rect); }
public API_GuiAutomation launchRdpClient(string ipAddress, string username, string password) { var terminalServicesClient = Processes.startProcess("mstsc.exe"); var guiAutomation = new API_GuiAutomation(terminalServicesClient); var window = guiAutomation.window("Remote Desktop Connection"); window.textBox("Computer:").set_Text(ipAddress); if (username.valid()) { window.button("Options ").click(); this.sleep(1000); window.textBox("User name:").set_Text(username); } window.button("Connect").mouse().click(); var loginWindow = guiAutomation.window("Windows Security", 3); if (password.valid()) { guiAutomation.keyboard_sendText(password); } loginWindow.button("OK").click(); return(guiAutomation); }
public static API_GitHub install_TortoiseGit(this API_GitHub gitHub, string msiPath) { var process = msiPath.startProcess(); var guiAutomation = new API_GuiAutomation(process); var tortoiseGitSetup = guiAutomation.windows()[0]; //tortoiseGitSetup.bringToFront(); //step 1 tortoiseGitSetup.button("Next >").mouse().click(); //step2 tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.radioButton("I accept the terms in the License Agreement").mouse().click(); tortoiseGitSetup.button("Next >").mouse().click(); //step3 tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.button("Next >").mouse().click(); //step4 tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.button("Next >").mouse().click(); //step5 tortoiseGitSetup = guiAutomation.windows()[0]; tortoiseGitSetup.button("Install").mouse().click(); //step6 for (int i = 0; i < 20; i++) { gitHub.sleep(2000, true); // wait 2 secs and try again tortoiseGitSetup = guiAutomation.windows()[0]; if (tortoiseGitSetup.button("Next >").isNull()) { tortoiseGitSetup.button("Finish").mouse().click(); break; } } return(gitHub); }
// need to convert to Tool_API format (this will uninstall public bool install() { "Installing {0}".info(ToolName); var downloadUrl = "http://downloads.sourceforge.net/project/gitextensions/Git%20Extensions/Version%202.17/GitExtensions217Setup.msi?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fgitextensions%2Ffiles%2FGit%2520Extensions%2FVersion%25202.17%2F&ts=1300699408&use_mirror=netcologne"; var targetDir = @"..\_O2Downloads".tempDir(false).fullPath(); var targetFile = targetDir.pathCombine(downloadUrl.uri().Segments.Last()); downloadUrl.download(targetFile); var process = targetFile.startProcess(); var guiAutomation = new API_GuiAutomation(process); guiAutomation.button("Next").click(); if (guiAutomation.hasButton("Repair")) { "App is already installed".error(); if (unInstallIfAlreadyInstalled) { guiAutomation.button("Repair").click(); guiAutomation.button("Next").click(); guiAutomation.button("Finish", 20).click(); } } else { guiAutomation.button("Next").click(); guiAutomation.button("Next").click(); guiAutomation.button("Next").click(); guiAutomation.button("Next").click(); guiAutomation.button("Install").click(); guiAutomation.button("Finish", 20).click(); }; return(false); }
public static List <Window> showDesktop(this API_GuiAutomation guiAutomation) { var desktopWindows = guiAutomation.desktopWindows(); foreach (var window in desktopWindows) { window.minimized(); } return(desktopWindows); }
public static Window desktopWindow(this API_GuiAutomation guiAutomation, string name) { foreach (var window in guiAutomation.desktopWindows()) { if (window.Name == name) { return(window); } } return(null); }
public static Window firstWindow(this API_GuiAutomation guiAutomation) { guiAutomation.sleep(100); // needed on install wizards that change windows quite quickly var windows = guiAutomation.windows(); if (windows.size() > 0) { return(windows[0]); } return(null); }
public static ListItem desktopIcon(this API_GuiAutomation guiAutomation, string name) { foreach (var icon in guiAutomation.desktopIcons()) { if (icon.Name == name) { return(icon); } } return(null); }
public static PopUpMenu getContextMenu(this API_GuiAutomation guiAutomation) { try { var emptyWindow = guiAutomation.desktopWindow(""); return(emptyWindow.Popup); } catch { } return(null); }
public static bool click_Button_in_Window(this API_GuiAutomation guiAutomation, string windowTitle, string buttonText, bool animateMouse, int timesToTry) { Func <bool> check = () => { var o2Timer = new O2Timer("click_Button_in_Window").start(); var scriptErrorWindow = guiAutomation.window(windowTitle); if (scriptErrorWindow.isNull()) { } //"didn't find window with title: {0}".error(windowTitle); else { var button = scriptErrorWindow.button(buttonText); if (button.isNull()) { } // "didn't find button with text: {0}".error(buttonText); else { "Found it: Clicking on button '{0}' in window '{1}' after {2} tries".debug(windowTitle, buttonText, timesToTry); if (animateMouse) { button.mouse(); } try { button.click(); } catch (Exception ex) { "[API_GuiAutomation][click_Button_in_Window] on or after clicking on button".error(ex.Message); } o2Timer.stop(); return(true); } } return(false); }; "Trying to find button '{0}' in window '{1}' for {2} tries".info(windowTitle, buttonText, timesToTry); for (int i = 0; i < timesToTry; i++) { var result = check(); if (result) { return(true); } } "Didn't find button '{0}' in window '{1}' after {2} tries".error(windowTitle, buttonText, timesToTry); return(false); }
public API_GUI_Automation_VisualStudio_2010 attach() { GUI = VS_Process = new API_GuiAutomation("devenv"); if (VS_Process.TargetProcess.notNull()) { VS_MainWindow = VS_Process.windows()[0]; //MAIN_WINDOW_TITLE); } else { start(); } return(this); }
public static API_GuiAutomation alwaysOnTop(this API_GuiAutomation guiAutomation, int windowHandle, bool value) { guiAutomation.window_Normal(windowHandle); // make sure the window is not minimized var HWND_TOPMOST = new HandleRef(null, new IntPtr(-1)); var HWND_NOTOPMOST = new HandleRef(null, new IntPtr(-2)); HandleRef hWndInsertAfter = value ? HWND_TOPMOST : HWND_NOTOPMOST; API_GuiAutomation_NativeMethods.SetWindowPos(windowHandle, hWndInsertAfter, 0, 0, 0, 0, 3); return(guiAutomation); }
public static Window window(this API_GuiAutomation guiAutomation, string windowName) { if (guiAutomation.notNull()) { foreach (var window in guiAutomation.windows()) { if (window.Name == windowName) { return(window); } } } return(null); }
//window public static API_GuiAutomation button_Click(this API_GuiAutomation guiAutomation, string windowName, string buttonName) { var window = guiAutomation.window(windowName); if (window.notNull()) { var button = window.button(buttonName); if (button.notNull()) { button.mouse().click(); } } return(guiAutomation); }
public static API_GuiAutomation attach(this API_GuiAutomation guiAutomation, string title) { try { guiAutomation.Application = Application.Attach(title); guiAutomation.TargetProcess = guiAutomation.Application.Process; return(guiAutomation); } catch (Exception ex) { ex.log("in attach"); return(null); } }
public static API_GitHub gitClone(this API_GitHub gitHub, string url, string targetDir, string privateKeyFile) { if (targetDir.inValid()) { targetDir = "".tempDir(); } var guiAutomation = new API_GuiAutomation(); if (guiAutomation.desktopWindow("Git clone").isNull()) // see if there is already an 'Git clone' window { //Create a form window with a webbrowser that will open a local folder var windowName = "This is Git Clone target folder (id:{0})".format(3.randomNumbers()); var topPanel = O2Gui.open <Panel>(windowName, 600, 200); var webBrowser = topPanel.add_WebBrowser_Control(); webBrowser.open(targetDir); webBrowser.mouse_MoveTo_WinForm(); // get the form and right click on it var window = guiAutomation.desktopWindow(windowName); guiAutomation.mouse().click().rightClick(); // get the context menu and click on the 'Git Clone...' menu button var contextMenu = guiAutomation.getContextMenu(); contextMenu.menu("Git Clone...").mouse().click(); } // get the Git Clone window var gitClone = guiAutomation.desktopWindow("Git clone", 10); gitClone.bringToFront(); // get a reference to the textboxes we will need to populate var url_TextBox = gitClone.textBox("Url: "); var directory_TextBox = gitClone.textBox("Directory:"); var puttyKey_TextBox = gitClone.textBoxes().id(1571); if (url.valid()) { url_TextBox.set_Text(url); } if (privateKeyFile.valid() && privateKeyFile.fileExists()) { puttyKey_TextBox.set_Text(privateKeyFile); } //directory_TextBox.set_Text(targetDir); // no need to do this since it is added when we use the context menu // Click button gitClone.button("OK").mouse().click(); return(gitHub); }
public static List <Window> windows(this API_GuiAutomation guiAutomation) { try { if (guiAutomation.notNull() && guiAutomation.Application.notNull()) { return(guiAutomation.Application.GetWindows()); } } catch (Exception ex) { ex.log(); } return(new List <Window>()); // do a soft landing }
public static List <Window> desktopWindows(this API_GuiAutomation guiAutomation) { for (int i = 0; i < 5; i++) { try { return(WindowFactory.Desktop.DesktopWindows()); } catch (Exception ex) { ex.log("in API_GuiAutomation in desktopWindows"); } } return(null); }
public static Window window(this API_GuiAutomation guiAutomation, string windowName, int numberOfTries) { for (int i = 0; i < numberOfTries; i++) { var window = guiAutomation.window(windowName); if (window.notNull()) { "after {0} tries, found window with title: {1}".info(i, windowName); return(window); } guiAutomation.sleep(1000, false); } "after {0} tries, cound not find window with title: {1}".info(numberOfTries, windowName); return(null); }
public static Button button(this API_GuiAutomation guiAutomation, string text, int waitCount) { "Trying {0} times to find button '{1}'".info(waitCount, text); for (int i = 0; i < waitCount; i++) { guiAutomation.sleep(2000, true); // wait 2 secs and try again try { var button = guiAutomation.button(text); if (button.notNull()) { return(button); } } catch {} } "Could not find button '{0}'".error(text); return(null); }
public bool install() { "Installing {0}".info(ToolName); startInstaller_FromMsi_Web(); if (this.Install_Process.notNull()) { var guiAutomation = new API_GuiAutomation(this.Install_Process); //step 1 guiAutomation.windows()[0] .button("Next >") .mouse().click(); //step 2 var acceptTerms = guiAutomation.windows()[0]; acceptTerms.radioButton("I accept the terms in the License Agreement") .mouse().click(); acceptTerms.button("Next >") .mouse().click(); //step 3 guiAutomation.windows()[0] .button("Next >") .mouse().click(); //step 4 guiAutomation.windows()[0] .button("Install") .mouse().click(); //step5 for (int i = 0; i < 20; i++) { this.sleep(2000, true); // wait 2 secs and try again var tortoiseGitSetup = guiAutomation.windows()[0]; if (tortoiseGitSetup.button("Next >").isNull()) { tortoiseGitSetup.button("Finish").mouse().click(); break; } } } return(isInstalled()); }
public override bool unInstall() { if (this.isInstalled() && this.Uninstall_Exe.fileExists()) { "[API_Fiddler] Starting Fiddler UnInstall process".info(); var guiAutomation = new API_GuiAutomation(); guiAutomation.launch(this.Uninstall_Exe); var processID = guiAutomation.TargetProcess.Id; //var finder = new AutomationElementFinder(AutomationElement.RootElement); var uninstallWindow = guiAutomation.desktopWindow("Fiddler2 Uninstall: Confirmation"); uninstallWindow.button("Uninstall").click(); uninstallWindow.button("Close").click(); "[API_Fiddler] Fiddler UnInstall complete".info(); if (this.isInstalled().isFalse()) { return(true); } "[API_Fiddler] There was an error in the UnInstall process (since fiddler is still installed)".info(); return(false); } "[API_Fiddler] in unInstall, Fiddler is not installed, so nothing to do".debug(); return(false); }
public static API_GuiAutomation keyboard_sendText(this API_GuiAutomation guiAutomation, string text) { guiAutomation.keyboard().text(text); return(guiAutomation); }
public static Keyboard keyboard(this API_GuiAutomation guiAutomation) { return(Keyboard.Instance); }
public static API_GuiAutomation mouse_RightClick(this API_GuiAutomation guiAutomation) { guiAutomation.mouse().rightClick(); return(guiAutomation); }
public static API_GuiAutomation mouse_DoubleClick(this API_GuiAutomation guiAutomation) { guiAutomation.mouse().doubleClick(); return(guiAutomation); }