We Are Going To Discuss About org.testng.TestNGException : Cannot instantiate class. So lets Start this Java Article.
org.testng.TestNGException : Cannot instantiate class
- org.testng.TestNGException : Cannot instantiate class
The lowest 'caused by' section points you to the underlying exception in your base class constructor: you are calling
System.getProperty
with a file path; that will probably return null. To me it looks like the whole call shouldn't be there, and you just want to pass the file path to theFileInputStream
constructor (or read it from a system property with some key) - org.testng.TestNGException : Cannot instantiate class
The lowest 'caused by' section points you to the underlying exception in your base class constructor: you are calling
System.getProperty
with a file path; that will probably return null. To me it looks like the whole call shouldn't be there, and you just want to pass the file path to theFileInputStream
constructor (or read it from a system property with some key)
Solution 1
The lowest ’caused by’ section points you to the underlying exception in your base class constructor: you are calling System.getProperty
with a file path; that will probably return null. To me it looks like the whole call shouldn’t be there, and you just want to pass the file path to the FileInputStream
constructor (or read it from a system property with some key)
Original Author OhleC Of This Content
Solution 2
Looking at the code, I understand the issue is in the constructor of the base class.
LoginPageTest calls super() which invokes TestBase.
FileInputStream needs a file path. I suspect FileInputSteam object created is coming as null.
Why are you calling System.getProperty? Is the config.properties file available?
Original Author sette Of This Content
Solution 3
Just Remove System.getproperty
from your base class. Use this lines of code
prop = new Properties();
FileInputStream ip = new FileInputStream(("C:\\Users\\RxLogix\\eclipse-workspace\\PviIntake\\src\\main\\java\\com\\pvi\\qa\\config\\config.properties"));
prop.load(ip);
Original Author Rajeev Ranjan Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.