public void CheckLetterDelete() { StartPage startPage = new StartPage(driver); EmailBox emailBox = new EmailBox(driver); startPage.Login(); try { emailBox.ClickLetterCheckbox("Видалення"); string xpath = "//span[text()='" + "Видалення" + "']/ancestor::div[@class='row new']//input"; //!!! name?? if (driver.FindElement(By.XPath(xpath)).Displayed) { IWebElement CheckBox = driver.FindElement(By.XPath(xpath)); emailBox.ClickDeleteBtn(); Actions action = new Actions(driver); IAlert alert = driver.SwitchTo().Alert(); alert.Accept(); emailBox.CheckLetterPresense("Видалення"); } } catch (NoSuchElementException exception) { Console.WriteLine("Sorry, we couldn't find a proper element"); } }