How to stop test execution in Selenium if an error occured?

0 votes
How to stop test execution in Selenium if an error occured?
Jul 4, 2019 in Selenium by Fatima
3,731 views

1 answer to this question.

+1 vote

Hey Fatima, if you are using any try-catch block in your code and wants to stop the test execution if an error is caught, then you can use this in your catch block:

try {
   //code
} 
catch(Exception e){
   e.printStackTrace();
   System.exit(1)
}
answered Jul 4, 2019 by Abha
• 27,930 points

Related Questions In Selenium

0 votes
1 answer
0 votes
3 answers

How to use JavaScript in selenium to click an Element?

WebElement element = driver.findElement(By.id("id")); JavascriptExe ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
30,667 views
0 votes
1 answer

How to select an Object by its class in Selenium?

When it comes to Selenium, XPath will ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,710 points
145 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,510 points
3,487 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,492 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,574 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
2,812 views
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 27,930 points
706 views