Selenium Framework - Part 35 - Creating your own Exception

preview_player
Показать описание
Hi All,

In this video, I have explained about how to create our own custom exceptions.
Apart from this, I have also explained why try catch is not always a best approach.
How Runtime Exception can help in solving the issues?
How selenium developers have developed their own exception?
How to customize the existing stack trace?

Рекомендации по теме
Комментарии
Автор

Finaly understood about to create customize exception. Thanks for sharing some amazing stuff.

manikannanmarimuthu
Автор

Amazing industry standard framework explanation. I would recommend everyone who wants to learn industry level framework standard they will find it here. This has helped me a lot Amuthan.i have not seen anywhere who has explained exception handling so crisp and clear, even paid videos.

I have a question
Inside catch block can I use
Log.error(" some error message"
And
Throw new runtime exception ("some error message")

supriyassampath
Автор

This is great work Amuthan!!
Please keep coming up with such kind of contents.
Big fan of your channel 🙌🙌🙌

subhadeepchakraborty
Автор

Able to understand core JAva concepts much better through your videos.

jaysree
Автор

Another great video Amuthan.Thank you.

lka
Автор

Thanks.amruthan for this amazing concept. Just One doubt.. Do we need to use try catch in Page class Or test class to.handle selenium.exceptions, if yes how to do it.in a effective way

Автор

Do this in your catch block and you will have printed the complete stacktrace in your runtime exception. This will give you the exact line of code in the method that caused the exception.

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
throw new

askomdch
Автор

Hi Amuthan, there are 2 private videos in playlist, are they some thing related to this frame work ?

rajasekharmaddigalla
Автор

How to handle situation where we get NosuchElementException from selenium but the actual root cause is button has not been clicked due to some reasons and failed to land to next page to check visibility of another element. Here when the element(button) has not been clicked the program should terminate there itself with throwing exception that element has not been clicked.

shrutimendiratta
Автор

Hello Amuthan,
Does this mean that it is better to create a separate Java class for all the common exceptions we might face in framework?

aryan
Автор

HI Amuthan, Can you please create one video on where we have used/Implemented it in your framework.

Thanks :)

manoharch
Автор

hey @TestingMiniBytes although concept is very good i encountered a problem i made the runtime exception for config file key value not prsent that eg url
but when i run i saw browser opening and then nothing happened prog got terminated due to our custom runtime exception but browser didnt close beacuse abrupt termination

ajitcs
Автор

Hi, you said you gonna make a separate video on hard coding ofTRY AND CATCH OF which MAKES US TO SEE THE CODE VERY CLOGGING AND UGLY, , are you going to add a new class and adding that in separate folder...so you can recall that method by using get ????

I didn't seen that you made that part till now

kranthikumarkatta
Автор

Bro may I know how many videos still pending for completion of the selenium course

Can we know what has covered and what still pending for interview point of view and subject point of view

kranthikumarkatta
Автор

Hi amuthan, using custom exception we will not be getting the JVM thrown exception. Without that how would we know what exactly is the issue for the failure ?? Also solution to this exception can be found in stack overflow etc sites but if we make custom made exception then we will not get those because those solution are associated with the runtime exception. Please suggest.

xoda
Автор

Hi bro my java version is 11 got some doubts in Exception handling..
when I am inserting line 1 inside try with resource block then on exception it is going to catch block and printing all customized stack inside try with resource block when I am using only fi(which we can do only after java version 9)
then it is not entering catch block...but I am not able to find the reason for it can you help please..sorry for bit big lengthy text

fi=new FileInputStream(new
try(FileInputStream fi=new FileInputStream(new
{
//reading m excel data as map


}
catch(FileNotFoundException e)
{
System.out.println("inside Filenot found exception");
StackTraceElement[] a=e.getStackTrace();
System.out.println("a[0] is"+a[0]);
a[0]=new StackTraceElement("com.opentesting.utils.ExcelUtils", "readExceldatainmap", "ExcelUtils.java", 67);
e.setStackTrace(a);
throw new RuntimeException("The file path is invalid", e);
}

sagars