public void DeleteAllProductsInCart() { ProductsWithShortcut[0].Click(); while (RemoveButtonsList.Count > 0) { var currentRemovedProduct = driver.FindElement(By.XPath("//*[@name='remove_cart_item']")); var currentNumberOfRemoveButtons = GetRemoveButtons().Count; var currentNumberOfProductsWithShortkut = GetProductsWithShortcut().Count; var removedProductName = driver.FindElement(By.XPath("//*[@name='remove_cart_item']/../..//a")).Text; var quantityRemovedProduct = driver.FindElement(By.Name("quantity")); if (int.Parse(quantityRemovedProduct.GetAttribute("value")) > 1) { quantityRemovedProduct.Clear(); quantityRemovedProduct.SendKeys("1"); } RemoveBtn = GetRemoveButtonForProduct(); RemoveBtn.Сlick(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until( ExpectedConditions.InvisibilityOfElementWithText(By.CssSelector("[class ='dataTable rounded-corners'] td.item"), removedProductName)); ProductsWithShortcut = GetProductsWithShortcut(); RemoveButtonsList = GetRemoveButtons(); OrderSummaryItems = GetOrderSummaryItems(); } }
private void DataGrid_KeyDown(object sender, KeyEventArgs e) { // удаление из базы по нажатию на Del if (e.Key == Key.Delete) { RemoveBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } else if (e.Key == Key.Enter) { EditBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); } }