private static CruciatusElement OpenChrome(string testPageAddress) { var chromeWindow = new Cruciatus.Application(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"); chromeWindow.Start("--force-renderer-accessibility --start-maximized --app=" + testPageAddress); Thread.Sleep(3000); var chromeFinder = By.Name("Яндекс.Диск").AndType(ControlType.Window); var chrome = Cruciatus.CruciatusFactory.Root.FindElement(chromeFinder); Thread.Sleep(100); #region Login try { while (true) { try { CruciatusElement ce = chrome.FindElementByName("Логин"); while (!ce.Text().Equals("Логин")) { ce.Click(); String backspace = "{BACKSPACE}"; String delete = "{DELETE}"; String clearstr = ""; for (int i = 0; i < ce.Text().Length; i++) { clearstr += backspace + delete; } Cruciatus.CruciatusFactory.Keyboard.SendText(clearstr); } ce.SetText(login); Thread.Sleep(100); break; } catch (Exception) { } } chrome.FindElementByName("Пароль").SetText(password); Thread.Sleep(100); chrome.FindElementByName("Войти ").Click(); Thread.Sleep(3000); } catch (Exception) { Console.WriteLine("Logged"); } #endregion #region Close helpers // Save password? try { chrome.FindElementByName("Нет").Click(); Thread.Sleep(100); } catch (Exception) { } // Install yandex disk on your computer // try { chrome.FindElementByName("Имя ").Click(); Thread.Sleep(100); } catch (Exception) { } #endregion return(chrome); }
/// <summary> /// Кликнуть по элементу с зажатой кнопкой Control /// </summary> public static void ClickWithPressedCtrl(this CruciatusElement element) { if (element == null) { throw new ArgumentNullException("element"); } var keyboardSimulatorExt = (KeyboardSimulatorExt) CruciatusFactory.GetSpecificKeyboard(KeyboardSimulatorType.BasedOnInputSimulatorLib); keyboardSimulatorExt.KeyDown(VirtualKeyCode.CONTROL); element.Click(); keyboardSimulatorExt.KeyUp(VirtualKeyCode.CONTROL); }
public static void ClickWithPressedKeys(this CruciatusElement element, List <VirtualKeyCode> keys) { keys.ForEach(key => CruciatusFactory.Keyboard.KeyDown(key)); element.Click(); keys.ForEach(key => CruciatusFactory.Keyboard.KeyUp(key)); }
/// <summary> /// Кликает по заданной кнопке диалогового окна. /// </summary> /// <param name="dialogWindow"> /// Диалоговое окно. /// </param> /// <param name="buttonsType"> /// Тип набора кнопок диалогово окна. /// </param> /// <param name="targetButton"> /// Целевая кнопка. /// </param> public static void ClickButton( CruciatusElement dialogWindow, MessageBoxButton buttonsType, MessageBoxResult targetButton) { if (dialogWindow == null) { throw new ArgumentNullException("dialogWindow"); } var condition = new PropertyCondition(WindowPattern.IsModalProperty, true); var modalwindow = AutomationElementHelper.FindFirst(dialogWindow.Instance, TreeScope.Children, condition); if (modalwindow == null) { throw new CruciatusException("NOT CLICK BUTTON"); } string uid; if (targetButton == MessageBoxResult.None) { uid = CruciatusFactory.Settings.MessageBoxButtonUid.CloseButton; } else { switch (buttonsType) { case MessageBoxButton.OK: switch (targetButton) { case MessageBoxResult.OK: uid = CruciatusFactory.Settings.MessageBoxButtonUid.OkType.Ok; break; default: throw new CruciatusException("NOT CLICK BUTTON"); } break; case MessageBoxButton.OKCancel: switch (targetButton) { case MessageBoxResult.OK: uid = CruciatusFactory.Settings.MessageBoxButtonUid.OkCancelType.Ok; break; case MessageBoxResult.Cancel: uid = CruciatusFactory.Settings.MessageBoxButtonUid.OkCancelType.Cancel; break; default: throw new CruciatusException("NOT CLICK BUTTON"); } break; case MessageBoxButton.YesNo: switch (targetButton) { case MessageBoxResult.Yes: uid = CruciatusFactory.Settings.MessageBoxButtonUid.YesNoType.Yes; break; case MessageBoxResult.No: uid = CruciatusFactory.Settings.MessageBoxButtonUid.YesNoType.No; break; default: throw new CruciatusException("NOT CLICK BUTTON"); } break; case MessageBoxButton.YesNoCancel: switch (targetButton) { case MessageBoxResult.Yes: uid = CruciatusFactory.Settings.MessageBoxButtonUid.YesNoCancelType.Yes; break; case MessageBoxResult.No: uid = CruciatusFactory.Settings.MessageBoxButtonUid.YesNoCancelType.No; break; case MessageBoxResult.Cancel: uid = CruciatusFactory.Settings.MessageBoxButtonUid.YesNoCancelType.Cancel; break; default: throw new CruciatusException("NOT CLICK BUTTON"); } break; default: throw new CruciatusException("NOT CLICK BUTTON"); } } var buttonElement = new CruciatusElement(dialogWindow, modalwindow, null).FindElement(By.Uid(uid)); buttonElement.Click(); }
public double GetSquare() { bttnSquare.Click(); return(GetCalculatorResult()); }