public static void VerifyAndAssertElementByXpath(string xPath, string expectedValue) { WaitHelper.WaitForElement(By.XPath(xPath), 5); string saleOdometerValue = WebDriverHelper.Driver.FindElement(By.XPath(xPath)).GetAttribute("value"); Assert.AreEqual(expectedValue, saleOdometerValue); }
public static void DeleteSkill() { //Delete Skill after changing tab and waiting for elements to be interactable tabSkill.Click(); WaitHelper.WaitClickble(Driver.driver, buttonDeleteSkill); buttonDeleteSkill.Click(); }
protected T DoSafe <T>(Func <T> action, int timeout) { var methodName = new StackFrame(1).GetMethod().Name; var message = $"Action {methodName} was failed with retry in {timeout / 1000} seconds. Error:\n"; var error = string.Empty; var result = default(T); Wait(() => { try { result = WaitHelper.DoSafe(action, methodName, timeout); error = string.Empty; return(true); } catch (StaleElementReferenceException e) { Element = null; Find(_by, _locator); error = e.ToString(); return(false); } }, () => message + error, timeout, Settings.WaitStrategy); return(result); }
public static void OpenDescriptionTextfield() { //Wait for the Profile details to be interactable and clicks it WaitHelper.WaitClickble(Driver.driver, buttonEditDescription); buttonEditDescription.Click(); Thread.Sleep(300); }
public override void Close() { try { string currentPort = SerialPort.PortName; Logger?.Info($"Closing {currentPort}..."); SerialPort.Close(); Logger?.Info($"Waiting for virtual port {currentPort} to disappear..."); const int timeoutVirtualPointDisappearance = 10000; const int virtualPortDisappearanceInterval = 100; string result = WaitHelper.WaitFor( timeoutVirtualPointDisappearance, virtualPortDisappearanceInterval, () => SerialPortStream.GetPortNames().Contains(currentPort) ? null : currentPort, (i, item, interval) => item == null ? $"T+{i * interval} - Port still present..." : $"T+{i * interval} - Port disappeared: {item}!" ); if (result == null) { Logger?.Warn( $"Virtual COM port {currentPort} was still present " + "after {timeoutVirtualPointDisappearance} ms!" ); } } catch (Exception ex) { throw new ArduinoUploaderException($"Exception during close of the programmer: '{ex.Message}'."); } }
public void SendKeys(string text) => WaitHelper.GetExplicitWait(exceptionTypes: new[] { typeof(StaleElementReferenceException), typeof(ElementClickInterceptedException), typeof(ElementNotInteractableException) }) .Until(d => { WebElementImplementation.SendKeys(text); return(true); });
internal static void SelectFromDropdown(By locator, string value) { select = new SelectElement(WaitHelper.ElementToBeClickable(locator)); ClickOn(locator); select.SelectByText(value); ReportHelper.PassLog("Successfully dropdown option is selected: <br>" + value + "<br>" + locator.ToString()); }
protected void Close(Process process) { if (process == null) { return; } if (process.HasExited) { return; } process.CloseMainWindow(); process.WaitForExit(TimeSpan.FromSeconds(10).Milliseconds); if (!process.HasExited) { process.Kill(); WaitHelper.Wait(40.Second(), () => { try { Process.GetProcessById(process.Id); return(false); } catch (ArgumentException) { return(true); } }); } }
private void _tlReports_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (_tlReports.FocusedNode == null) { return; } _reportItem = _tlReports.FocusedNode.Tag as ReportItem; if (_reportItem == null) { return; } if (_reportItem.Content == null || _reportItem.Content.Length == 0) { MessageBoxHelper.Warn("未设计的报表。"); return; } using (WaitHelper.ShowWaitForm("报表加载中", AppHelper.MainForm)) { var wraper = new ReportWraper(_reportItem.DataSource, _reportItem.Content); documentViewer1.DocumentSource = wraper.CreateReport(); documentViewer1.Refresh(); } }
public void WhenUserMouseHoverOnShopProductsLink() { WaitHelper.WaitUntil(() => PageStorage.GetPage <HomePage>().Shop_Products_Header_Link.Displayed); Actions actions = new Actions(PageStorage.Driver); actions.MoveToElement(PageStorage.GetPage <HomePage>().Shop_Products_Header_Link).Perform(); }
private void ActivateColorMatch(GameEntity colorMatch) { var touchedCube = _contexts.game.GetEntityWithId(colorMatch.colorMatch.TouchedCubeId); var matchId = touchedCube.matchGroup.Id; var matchCount = touchedCube.matchGroup.Count; var cubes = _contexts.game.GetEntitiesWithMatchGroup(matchId); var removerId = IdHelper.GetNewRemoverId(); if (matchCount < 5) { WaitHelper.Increase(WaitType.Turn); foreach (var cube in cubes) { ActivateColorCube(cube, removerId); cube.AddWillExplode(1); } WaitHelper.Reduce(WaitType.Turn); } else { //this stops event async ActivateSpecialColorMatch(touchedCube, cubes, removerId).Start(); } }
// navigate to Time and Material page public void NavigateToTM(IWebDriver driver) { // Navigate to Time and Material page driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/a")).Click(); WaitHelper.WaitClickable(driver, "XPath", "/html/body/div[3]/div/div/ul/li[5]/ul/li[3]/a", 5); driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/ul/li[3]/a")).Click(); }
//Function to Delete TM public void deleteTM() { HomePage homeObj = new HomePage(driver); Thread.Sleep(3000); WaitHelper.WaitClickable(driver, "XPath", ".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]", 5); //Calling Last Page function homeObj.LastPage(driver); // Find and click on delete button driver.FindElement(By.XPath(".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[5]/a[2]")).Click(); driver.SwitchTo().Alert().Accept(); // WaitHelper.WaitClickable(driver, "XPath", ".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]", 5); //Calling Last Page function homeObj.LastPage(driver); // Check record is in list IWebElement delrecord = driver.FindElement(By.XPath(".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]")); if (delrecord.Text == "7777") { Assert.Fail("Record not delete, Test failed"); } else { Assert.Pass("Record Deleted, Test Pass"); } }
public AddContractPage FillAndVerifyDealSetupFormFields(AddContractPage ContractSetup) { WaitHelper.WaitForElement(By.XPath(vehicleInformationPath), 10); Driver.FindElement(By.XPath(saleOdometerPath)).SendKeys(ContractSetup.SaleOdom); VerifyAndAssertElementByXpath(saleOdometerPath, ContractSetup.SaleOdom); Driver.FindElement(By.XPath(vinPath)).SendKeys(ContractSetup.Vin); VerifyAndAssertElementByXpath(vinPath, ContractSetup.Vin); Driver.FindElement(By.XPath(financeTypePath)).SendKeys(ContractSetup.FinanceType); VerifyAndAssertElementByXpath(financeTypePath, ContractSetup.FinanceType); var element = Driver.FindElement(By.XPath(amountFinancedPath)); element.Click(); element.SendKeys(ContractSetup.AmountFinanced); VerifyAndAssertElementByXpath(amountFinancedPath, expectedAmountFinancedValue); Driver.FindElement(By.XPath(financeTermPath)).SendKeys(ContractSetup.FinanceTerm); VerifyAndAssertElementByXpath(financeTermPath, ContractSetup.FinanceTerm); Driver.FindElement(By.XPath(lenderNumberPath)).SendKeys(ContractSetup.LenderNumber); VerifyAndAssertElementByXpath(lenderNumberPath, ContractSetup.LenderNumber); return(this); }
public DashboardPO(IWebDriver driver) { this.driver = driver; wait = new WaitHelper(driver); byReportIssue = By.LinkText("Report Issue"); byViewIssues = By.LinkText("View Issues"); }
public static void DeleteEducation() { //Delete Education after changing tab and waiting for elements to be interactable tabEducation.Click(); WaitHelper.WaitClickble(Driver.driver, buttonDeleteEducation); buttonDeleteEducation.Click(); }
private void GenerateItem(GameEntity generator, int amount, ItemTypeInBoard type, bool bottomCellConsiderate, GeneratorRadius generatorRadius) { var generationAmount = generator.goalEffectType.Type == GoalEffectType.Decrease ? CalculateGenerationAmountForItem(type, amount) : amount; var positionsToCheck = GetPositionsToCheck(generator.gridPosition.value, generatorRadius); var itemIds = SelectSuitableItems(positionsToCheck, bottomCellConsiderate).Shuffle().Take(generationAmount) .ToList(); var reservations = new List <Tuple <int, int> >(); foreach (var id in itemIds) { var reservationId = IdHelper.GetNewReservationId(); var item = _contexts.game.GetEntityWithId(id); item.AddItemReservation(reservationId, id, type); reservations.Add(new Tuple <int, int>(reservationId, id)); WaitHelper.Increase(WaitType.CriticalAnimation); } generator.AddReservedItems(reservations); if (generator.goalEffectType.Type == GoalEffectType.Decrease) { _contexts.game.goalForGenerators.Goals[type.GoalType] -= generationAmount; if (CalculateItemLeftToGenerate(type) == 0) { CloseGenerators(generator); } } }
public static void DeleteCertificate() { //Delete Certificate after changing tab and waiting for elements to be interactable tabCertificates.Click(); WaitHelper.WaitClickble(Driver.driver, buttonDeleteCertificate); buttonDeleteCertificate.Click(); }
internal static void SendKeys(By locator, string text) { element = WaitHelper.ElementIsVisible(locator); element.Clear(); element.SendKeys(text); ReportHelper.PassLog("Successfully text inserted into: <br>" + text + "<br>" + locator.ToString()); }
private void ActivateRotorRotor(GameEntity entity) { WaitHelper.Increase(WaitType.CriticalAnimation); CellHelper.BlockFallAt(entity.gridPosition.value); entity.isSpawnAnimationStarted = true; }
protected override void Execute(List <GameEntity> entities) { foreach (var tntTnt in entities) { tntTnt.isSpawnAnimationStarted = false; tntTnt.isSpawnAnimationEnded = false; var pos = tntTnt.gridPosition.value; var radius = tntTnt.tntTnt.Radius; var removerId = IdHelper.GetNewRemoverId(); for (int x = pos.x - radius; x <= pos.x + radius; x++) { for (int y = pos.y - radius; y <= pos.y + radius; y++) { CellHelper.UnBlockFallAt(new Vector2Int(x, y)); ActivatorHelper.TryActivateItemWithPositive(new Vector2Int(x, y), removerId, ActivationReason.Tnt); } } tntTnt.isWillBeDestroyed = true; WaitHelper.Reduce(WaitType.Input, WaitType.Turn, WaitType.CriticalAnimation); } }
public async Task ShouldStartImmediately() { // Arrange var heartbeatCompleted = false; this.schedulerMetadataStore.Setup(s => s.Heartbeat(this.schedulerId)).Returns(async() => { await Task.Delay(500); heartbeatCompleted = true; }); // Act var sw = Stopwatch.StartNew(); await this.sut.Start(); var startTime = sw.Elapsed; await WaitHelper.WaitForAction(() => heartbeatCompleted); sw.Stop(); // Assert Assert.True(startTime.TotalMilliseconds < 100); Assert.True(sw.ElapsedMilliseconds >= 500); }
public static void FillCardField() { WaitHelper.WaitClickble(Driver.driver, buttonEditDescription); EditAvailability(); EditHours(); EditEarnTarget(); }
// navigate to Employee page public void NavigateToEmployee(IWebDriver driver) { // Navigate to Employee page driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/a")).Click(); WaitHelper.WaitClickable(driver, "XPath", "/html/body/div[3]/div/div/ul/li[5]/ul/li[3]/a", 2); driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/ul/li[3]/a")).Click(); }
private IWebElement TryFindSingle() { try { return(FindSingleIWebElement()); } catch (StaleElementReferenceException) { ClearSearchResultCache(); WaitHelper.Wait(driver.WaitProfile.PollingInterval.Milliseconds); return(FindSingleIWebElement()); } catch (InvalidSelectorException) { throw; } catch (WebDriverException) { throw; } catch (WebElementNotFoundException) { throw; } catch { throw;// WebElementNotFoundException; } }
public void Delay_of_payment() { //нужно что бы отработала логика в StartCheck settings.LastLeaderCalculation = DateTime.MinValue; Fixture <LocalDelayOfPayment>(); var waitWindowAsync = manager.WindowOpened.Where(w => w.AsText().Contains("Пересчет отсрочки платежа")).Replay(); disposable.Add(waitWindowAsync.Connect()); StartWait(); var waitWindow = waitWindowAsync.Timeout(10.Second()).First(); Assert.That(waitWindow.AsText(), Does.Contain("Пересчет отсрочки платежа")); //ждем пока закроется WaitHelper.WaitOrFail(10.Second(), () => activeWindow != waitWindow); Click("ShowCatalog"); OpenOffers(); dispatcher.Invoke(() => { var offers = activeWindow.Descendants <DataGrid>().First(g => g.Name == "Offers"); var supplierCost = GetCell(offers, "Цена поставщика"); var cost = GetCell(offers, "Цена"); Assert.AreNotEqual(supplierCost.AsText(), cost.AsText()); }); }
private IEnumerator ActivatePuzzlePuzzle(GameEntity entity) { WaitHelper.Increase(WaitType.Input, WaitType.Fall, WaitType.Turn, WaitType.CriticalAnimation); yield return(DoWait.WaitWhile(() => entity.isCreatedFromMatch)); var width = _contexts.game.board.Size.x; var height = _contexts.game.board.Size.y; var pos = entity.gridPosition.value; var removerId = IdHelper.GetNewRemoverId(); var radius = 0; var radiusLimit = (int)Mathf.Sqrt(width * width + height * height) + 1; var visited = new bool[width, height]; while (radius < radiusLimit) { ProcessPuzzlePuzzle(pos, radius, removerId, visited); radius++; yield return(DoWait.WaitSeconds(0.07f)); } entity.isWillBeDestroyed = true; WaitHelper.Reduce(WaitType.Input, WaitType.Fall, WaitType.Turn, WaitType.CriticalAnimation); }
//это не будет работать на сервере, всего скорее диалоги там даже не отображаются public static void HandleOpenFileDialog(string filename) { var pid = Process.GetCurrentProcess().Id; AutomationElement dialog = null; AutomationElement input = null; WaitHelper.WaitOrFail(10.Second(), () => { dialog = AutomationElement.RootElement.FindFirst(TreeScope.Children, new AndCondition( new PropertyCondition(AutomationElement.NameProperty, "Открыть"), new PropertyCondition(AutomationElement.ProcessIdProperty, pid), new PropertyCondition(AutomationElement.ClassNameProperty, "#32770"))); if (dialog == null) { return(false); } input = dialog.FindFirst(TreeScope.Children, new AndCondition(new PropertyCondition(AutomationElement.NameProperty, "Имя файла:"), new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ComboBox))); return(input != null); }, "Не удалось дождаться появления диалога открытия файла"); input.SetValue(filename); var button = dialog.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Открыть")); button.Invoke(); }
/// <summary> /// Opens an excel file. /// </summary> /// <param name="path">File path.</param> public void OpenFile(string path) { WaitHelper.WaitFor(() => FileHelper.IsFileReady(path), 20); _workbook = RetryUtils.RetryIfThrown <COMException, Workbook>(() => _excelApp.Workbooks.Open(path), ConfigHelper.DefaultRetriesNumber, () => _workbook.Close()); }
public ViewIssuesPO(IWebDriver driver) { this.driver = driver; wait = new WaitHelper(driver); byIssuesTable = By.Id("buglist"); }