SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    New Member
    Join Date
    Sep 2015
    Location
    France
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Webdriver -> Is it a good practice to put printlns in "catch" ?

    Hello everyone,

    I'm discovering Selenium Webdriver and I realize there is fewer information than in Selenium IDE when there's a bug somewhere.
    That's why I'm wondering if I should do this on each piece of code :

    try {
    whatever;
    } catch (Error e) {
    verificationErrors.append(e.toString());
    System.out.println("Did not find the right value which was blablabla");
    }

    It may be a crazy idea, if so feel free to tell me ^^

    Cheers,

    Decapod

  2. #2
    SQA Knight
    Join Date
    May 2006
    Location
    Playa Del Rey, California, United States
    Posts
    2,593
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    Quote Originally Posted by decapod View Post
    Hello everyone,

    I'm discovering Selenium Webdriver and I realize there is fewer information than in Selenium IDE when there's a bug somewhere.
    That's why I'm wondering if I should do this on each piece of code :

    try {
    whatever;
    } catch (Error e) {
    verificationErrors.append(e.toString());
    System.out.println("Did not find the right value which was blablabla");
    }

    It may be a crazy idea, if so feel free to tell me ^^

    Cheers,

    Decapod

    Do what ever works with your team. I personally avoid catching and swallowing exceptions, especially top level exceptions like "Exception" and "RumtimeException" classes. It tends to hide the details of the issue, so you lose context of if it's a bug in your test, or the software under test. I would wrap it up in another exception, and add additional details to that exception class.

    Many unit test frameworks will have an Assert class that makes it easier.
    Assert.Equals(expectedValue, actualValue, messageToReasonWhyThisCheckFailed)
    David Lai
    SDET / Consultant
    LinkedIn profile

  3. #3
    Member
    Join Date
    May 2011
    Location
    California, US
    Posts
    306
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    I might use SOP just for debugging sometimes or directly debug line by line - as in case of exceptions, I would prefer to throw the stacktrace instead of some message.
    Also use both hard and soft asserts - whereever necessary.
    --
    Vijay

  4. #4
    Apprentice
    Join Date
    Apr 2015
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    You can use the logger API :

    if you are using the Logger API then use the below statement
    try{

    // statement which you want to monitor

    }catch(Exception e){
    log.error(e,e);
    }
    ##############################
    Or you can use the
    try{
    // statement which you want to monitor

    }catch(Exception e){
    e.printStackTrace()
    // OR System.err.println(e.getStackTrace());
    // OR System.err.println(e);
    // OR System.err.println(e.getMessage());
    // OR System.err.println(e.getCause());
    }
    Avoid to use System.out.println(). SInce this is very slow

  5. #5
    Apprentice
    Join Date
    Apr 2015
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    You can use the logger API :

    if you are using the Logger API then use the below statement
    try{

    // statement which you want to monitor

    }catch(Exception e){
    log.error(e,e);
    }
    ##############################
    Or you can use the
    try{
    // statement which you want to monitor

    }catch(Exception e){
    e.printStackTrace()
    // OR System.err.println(e.getStackTrace());
    // OR System.err.println(e);
    // OR System.err.println(e.getMessage());
    // OR System.err.println(e.getCause());
    }
    Avoid to use System.out.println(). SInce this is very slow

  6. #6
    Apprentice
    Join Date
    Apr 2015
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    You can use the logger API :

    if you are using the Logger API then use the below statement
    try{

    // statement which you want to monitor

    }catch(Exception e){
    log.error(e,e);
    }
    ##############################
    Or you can use the
    try{
    // statement which you want to monitor

    }catch(Exception e){
    e.printStackTrace()
    // OR System.err.println(e.getStackTrace());
    // OR System.err.println(e);
    // OR System.err.println(e.getMessage());
    // OR System.err.println(e.getCause());
    }
    Avoid to use System.out.println(). Since this is very slow

    Thanks
    QASource Team
    www.qasource.com

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:32 AM.

Copyright BetaSoft Inc.