How to stop button event when exception fired..?I used try catch blocks, if exception fired it will try to execute next code, i dont want that...pls check comments in code..M i using try catch blocks wrongly..?
here is my code:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
try
{
driver.FindElement(By.CssSelector(".username")).SendKeys("abc");
driver.FindElement(By.CssSelector(".password")).SendKeys("abcpassword");
driver.FindElement(By.XPath("//a[2]/img")).Click();
}
catch(Exception ex)
{
driver.Quit();
MessegeBox.Show("Log in failed");
//stop button event here only if exception fired
}
try
{
new SelectElement(driver.FindElement(By.Id("CId"))).SelectByText("CVB");
driver.FindElement(By.Name("ddd")).Click();
}
catch(Exception ex)
{
driver.Quit();
MessegeBox.Show("Log in failed");
//stop button event here only if exception fired
}
Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
xlApp.DisplayAlerts = false;
object misValue = System.Reflection.Missing.Value;
}
}
Aucun commentaire:
Enregistrer un commentaire