Image CAPTCHA
Enter the characters shown in the image.

You are here

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in book_prev() (line 775 of /home/aufr/public_html/modules/book/book.module).

Handling Exceptions in Selenium

 
Exceptions in Selenium:
  1. NoSuchElementException : Is thrown when "FindBy" method is not able to find the element. 
  2. StaleElementReferenceException : This tells that the element is no longer appears on the DOM page. 
  3. TimeoutException: This tells that the execution is failed because the command did not complete in enough time. 
  4. ElementNotVisibleException: Is thrown to indicate that although an element is present on the DOM, but it is not visible,  and so is not able to be interacted with .  
  5. ElementNotSelectable Exception:  Is thrown to indicate that the element is not Selectable, the possible causes for this might be that it is disabled .

 

Exception Handling in Selenium

A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code,
 
try { 
             // Some code
 } catch(Exception e){ 
           // Code for Handling the exception 
 }
 
Multiple Catch blocks: A try block can be followed by multiple catch blocks. Like I said earlier, that there are multiple exceptions and you can expect more than one type of exception on a single code block and if you like to handle each type of exception separately with a separate block of code.
 
try { 
             // Some code
 } catch(Exception1 e1){ 
           // Code for Handling the exception 1
}catch(Exception2 e2){ 
           // Code for Handling the exception 2
}
 
Note: If the exception does not match with any exception type mentioned in the catch blocks, then it falls through all catches, and exception is thrown, execution stops. That is why it is advisable to include default exception block (“finally”) as well in the end, so that in the worst scenario if no catch block is able to catch the exception , it can be handled by the default exception.
In some cases when we don't want the program to execute further if it encounters certain Exception, then we can use Throw .
 
Throws: When we are throwing any exception in a method , then we need to use throws keyword in methodsignature to let caller program know the exceptions that might be thrown by the method.
"Throwskeyword gives a method flexibility, of throwing an Exception rather than handling it.
 
Throw: "Throw" keyword is used to actually throw the exception at the run time .
Difference between Throws and Throw 
1) You can declare multiple exception thrown by method in throws keyword by separating them in common e.g. throws IO Exception, ArrayIndexBoundException etc, while you can throw only one instance of exception using throw keyword e.g. throw new IO Exception("not able to open connection").
2). While "Throws" can be used only  in method signature , whereas there are numerous places where we can use "Throw" :
       a)  anywhere  inside method or static initializer block 
static{
        try {
            throw new Exception("Can Not initialize");
        } catch (Exception ex) {
            Logger.getLogger(ExceptionTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
       b) "Throwcan also be used instead of "returnin a method.
public void shutdown() throws IOException{
        throw new IOException("Unable to shutdown");
 }
 
 private static boolean shutdown() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
Note that in the method shutdown() above, a boolean should be returned. But because we have "throw" in place of return , compiler understands that this method will always throw exception .
         c) "Throw" keyword can also be used instead of "break" keyword, to break out of a switch statement .
 
int number = 4;
switch(number){
            case 1:
                throw new RuntimeException("Exception number 1");
            case 2:
                throw new RuntimeException("Exception number 2");
        }
 
Finally
The "finally" keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred. Also it is useful in a case where exception is not caught by any of the "catch" blocks
try 
            { 
               //Protected code
 
            }catch(ExceptionType1 e1) 
            { 
               //Catch block 
            }catch(ExceptionType2 e2) 
            { 
               //Catch block 
            }catch(ExceptionType3 e3) 
            { 
               //Catch block 
 
            }finally 
            { 
               //The finally block always executes.
 
            }
 
 
About The Author: 

was copy and filter from reference


 

Displaying 1 - 15 of 123
Title Company Scope Application Rights User Interface Available Supported Technologies Maturity
JMeter Apache Test Automation Framework; Testing Tool Free Use; Opensource Batch Mode; Plugin; Stand Alone application JDBC Driver; JMS; LDAP CORBA; IMAP; POP3; SMTP; SOAP; Web; HTTP; HTTPS 1,999
QA Wizard Pro Seapine Software Testing Tool Commercial; Demo; Floating license; Static license; Trial; User license GUI usability; Remote Control; Remote Execution Adobe Flash; Adobe Flex; AJAX; Dot.NET; Java; Qt; Silverlight; VB App; Web; HTML; HTML5; JavaScript; Windows GUI/Forms; Win32 2,007
JSystem Top-Q Test Automation Framework; Testing Tool Free Use; Opensource Ant Integration; Batch Mode; GUI usability; Integrated into ALM; Integrated into IDE; Maven Integration; Plugin; Stand Alone application Web 2,011
Jelly Apache Test Automation Framework; Testing Tool Free Use; Opensource Batch Mode; JRE UI 2,010
Watir Watir.com Test Automation Framework; Testing Tool Free Use; Opensource Batch Mode; Command Line; GUI usability; Tool Extension RubyOnRails; Web 2,011
FitNesse GitHub project Test Automation Framework; Testing Tool Free Use; Opensource Batch Mode; Integrated into IDE; Plugin; Web based Database; MS SQL; MySQL; Oracle; SOAP; Swing; Web; HTML 2,009
Automation Anywhere Enterprise Automation Anywhere Testing Tool; Testing Utility; Automate Gui Commercial; Demo; Trial GUI usability; Stand Alone application 2,008
Unified Functional Testing Hewlett Packard Enterprise Test Automation Framework; Testing Tool Commercial; Demo; Free Use; Trial Batch Mode; COM API; GUI usability; Integrated into ALM; Remote Execution; Stand Alone application Adobe Flex; OCR; SAP; SAP Gui; Siebel; HTML; Windows GUI/Forms; Win32 2,000
eggPlant Functional TestPlant Monitoring Tool; Testing Tool; Emulator Commercial; Demo; Floating license; Static license; Subscription; Trial GUI usability; Integrated into ALM; Plugin; Remote Execution; Stand Alone application Adobe Flash; Adobe Flex; AJAX; Dot.NET; Java App; Java GUI; Image Verification; Mobile Applications; Android apps; Blackberry apps; Hybrid Apps; iPhone apps; Native Apps; Symbian apps; Web Apps; Windows Mobile apps; Mobile Features; RIA; Silverlight; Swing; Web; DHTML; HTML; SWT; Windows GUI/Forms 2,008
TestComplete SmartBear Software Test Automation Framework; Testing Tool Commercial; Floating license; Trial; User license COM API; Stand Alone application Adobe Air; Adobe Flash; Adobe Flex; C/C++; Dot.NET; Java; Java App; JavaFX; Delphi App; Microsoft Visual FoxPro; PowerBuilder; NTLM; Qt; RIA; Silverlight; VB App; Web; ASP; HTML; Windows GUI/Forms; Win32; WPF/XAML; XBAP 1,999
Tellurium (aost) Google Code Projects Test Automation Framework; Testing Tool Free Use; Opensource Ant Integration; Direct UI; Maven Integration; Plugin JavaScript; jQuery; Xpath 2,007
LDTP GitHub project Test Automation Framework; Testing Tool Free Use; Opensource GUI usability; Stand Alone application Java; Perl App; RubyOnRails 2,004
Ranorex Integrated Test Automation Tools Ranorex Test Automation Framework; Testing Tool; Testing Utility Commercial; Demo; Floating license; Static license; Trial Command Line; GUI usability; Integrated into IDE; Stand Alone application Adobe Air; Adobe Flash; Adobe Flex; AJAX; Dot.NET; Java; Java App; Java GUI; Java SWT; JavaFX; ComponentOne controls; Delphi App; Echo; Ext.Net; GWT; Image Verification; Infragistics; JSON; Microsoft Visual FoxPro; Mobile Applications; Android apps; Hybrid Apps; iPhone apps; Native Apps; Web Apps; Windows Mobile apps; Mobile Features; GPS testing; Mobile Bluetooth; Android; IOS; MochiKit; PowerBuilder; Qt; RIA; SAP; Sencha Touch; Silverlight; SmartClient; VB App; Web; DHTML; DHTMLX; HTML; HTML5; JavaScript; jQuery; Web2.0; Xpath; Windows GUI/Forms; ActiveX; MFC; Win32; Windows 10 Apps; WPF/XAML; YUI; ZK 2,007
Rational Functional Tester [RFT] IBM Rational Test Automation Framework; Testing Tool Commercial; Demo; Static license; Trial GUI usability; Integrated into ALM; Integrated into IDE; Stand Alone application Adobe Flex; AJAX; Code Testing; Dot.NET; Java; Java App; Java GUI; PowerBuilder; SAP; Siebel; Terminal Emulator 3270; Terminal Emulator 5250; VB App; Web; HTML; Windows GUI/Forms; MFC; MSExcel; MSOutlook; Windows 10 Apps 2,001
IQ Bot Automation Anywhere Testing Tool Commercial; Demo; Trial; User license Command Line; GUI usability Adobe Flex; AJAX; C/C++; Dot.NET; Java; Java App; Delphi App; Perl App; PHP; Silverlight; Web; HTML; Windows GUI/Forms; Win32; WPF/XAML 2,012

Pages

MANUFACTURERS Wallboard

Testing tool manufacturers world-wide list
10Levels ABID CONSULTING AccelQ Accord Software ActiMind AdaCore
AdaLog AgileLoad AgileWay Agitar Algorismi ALL4TEC
Andreas Kleffel Android Apache Apica Apollo Systems AppAssist.mobi
Applitools AppPerfect Appsee ApTest Assertible Assure
Atlassian AutoIt Consulti .. Automation Anyw .. Automation Cons .. Axosoft Aztaz Software
Backtrace I/O Badboy BlazeMeter Borvid BrowserStack BSQUARE
BStriker Intern .. CA Technologies Canonical Canoo Engineeri .. Catch Software CelestialTeapot
Chris Mallett Cleanscape ClicTest CloudQA Codeborne CodeCentrix
CodePlex projec .. Codoid Cogitek Compuware Configure IT Conflair
ConSol Core Services Coronys Ltd Countersoft CresTech Softwa .. CrossBrowserTes ..
Crosscheck Netw .. Crowdsourced Te .. Cucumber Ltd Cyara Cygnet Infotech DareBoost
Databene Datamatics Glob .. DevExpress DTM soft Dynatrace LLC EasyQA
Eclipse EkaTechserv Elvior Emmanuel Jorge Empirix EPAM Systems
Equafy Esterel Technol .. eXept Software .. Experitest Finaris Froglogic
FrontEndART Ltd GeneXus GitHub project gnoso Google Code Pro .. GrammaTech
Gurock Software HelpSystems HENIX Hewlett Packard .. Hexawise High-Tech Bridg ..
Hiptest Hitex IBM Rational imbus Shanghai Impetus Inflectra
informUp InTENSO - IT Ex .. Ipswitch Jamo Solutions Janova JAR Technologie ..
JBoss Developer jClarity Jellly.io JetBrains Jively jQuery foundati ..
JS Foundation Jspresso Kanoah KMS Technology Kualitee LDRA Limited
Litmus LoadFocus Loadster Perfor .. MarathonITE Marketcircle Marketcircle
Maveryx Meliora Ltd Micro Focus Sof .. Microsoft Mobile Labs Mobile1st
Mockaroo, LLC Monkop Mozila MSys Technologi .. Navicat NeoTys
Neowise Softwar .. NetCart NORIZZK.COM Novosync Mobili .. NRG Global NTT Resonant
OC Systems Odin Technology OpCord Oracle Orcanos Original Softwa ..
OW2 PANAYA Parasoft PassMark Patterson Consu .. Perfecto Mobile
Pivotal, Inc. Plutora Postman (API To .. PractiTest PrimaTest Process One
Programming Res .. Psoda PureLoad PushToTest Python Q-Assurance
QA Systems QACube QASymphony QAWorks QMetry Quali
Qualitia Softwa .. Quality First S .. Quotium RadView Softwar .. Ranorex RedLine13
Reflective Solu .. ReQtest RevDeBug Robotium Tech Rogue Wave Soft .. Rommana Softwar ..
RTTS ruby-doc.org Runscope Sandklef GNU La .. Sauce Labs Seapine Softwar ..
SeleniumHQ Sencha Sensiple Siemens PLM Sof .. SmartBear Softw .. SmarteSoft
SOASTA SoftLogica Softomotive Softsmith Solution-Soft SonarSource
Sourceforge Spirent Technol .. SQS Software Qu .. Square Stimulus Techno .. Swifting AB
Synopsys T-komp T-Plan TechExcel TechTalk Telerik By Prog ..
Tellurium Test Collab Test Goat Test Recon TestCaseLab testCloud.de Gm ..
TestCraft Techn .. Testenium Testim.io TestingBot TestLodge Testmunk
Testomato TestOptimal TestPlant TestPro Testsigma Techn .. Testuff
The Core Bankin .. The MathWorks The Open Group thePHP.cc Thoughtbot Thoughtworks
Tigris.org Time Simulator Top-Q Trace Technolog .. TrendIC TRICENTIS
Tritusa Pty Ltd TWD Solutions P .. TypeMock Tyto Software Ubertesters UniTESK
Universal Test .. Usetrace Ltd Utrecht Univers .. Validata Group Vanamco AG Vector Software
Veracode Verifaya Corpor .. Verit VersionOne Viewlike.us Vornex Inc.
Watir.com WcfStorm Soluti .. We Are Mammoth Web Performance .. Wintask Wireshark Found ..
Worksoft Xceptance XK72 Xpand IT XQual ZAPTEST
Zeenyx Software .. Zephyr Zeta Software zutubi pty

Selenium Youtube Playlist

Theme by Danetsoft and Danang Probo Sayekti