How to simulate the selenium exceptions?

17 views
Skip to first unread message

Summer Zhang

unread,
Jun 19, 2018, 3:38:02 AM6/19/18
to Selenium Users
Hi,
I want to catch the selenium exception org.openqa.selenium.SessionNotCreatedException, and now I want my case to throw this exception, then I can catch it, but I don't know how to simulate such a selenium exception in my case, anyone knows?
Thanks!

Joe Ward

unread,
Jun 19, 2018, 3:57:57 AM6/19/18
to seleniu...@googlegroups.com
Why would you throw an exception immediately to catch it? Why would you need to know exactly how to simulate an exception if you could just throw it programmatically? 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/73c94412-197a-4d2d-a8f5-81d134cbd829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

total QA

unread,
Jun 19, 2018, 4:17:49 AM6/19/18
to Selenium Users
Hi Zhang,

First catch the Exception, verify its type of the Exception. You would not require to simulate it, but catch it verify to perform particular action.

try{

}
catch(Exception e)//Exception is a super-class for all exceptions.
    if(e instanceOf  SessionNotCreatedException)
   {

   }
   else
   {

   }
}

Regards,
Reply all
Reply to author
Forward
0 new messages