Below is another way to create the HashMap, for (String key : properties.stringPropertyNames()) { propertiesMap.put(key, properties.getProperty(key)); }
Constructors are meant for instantiating instance members and static blocks helps to initialise static data members. It is also termed as eager initialisation and we can be sure that the data from property file will definitely be available for us to use. You can do that without static blocks using methods but what if there is an unhandled exception before calling method. Your entire test suite will fail because of NPE. The cause will be due to the property values are not read.
Amuthan Bro,if we have more than 1 Properties files ,it wouldnt help na in single static blocks, we have to create another static block, am i right?? please help me out on this
You can have it in the same static block. You can use another one too. It is entirely the way you code. There is no impact to the performance as such. But I would advice to limit the number of property files.
Hi, I am getting error at vidoe time :15:25, ConfigMap.put and the error is:The method put(String, DocFlavor.STRING) in the type HashMap is not applicable for the arguments (String, String) , please help me to fix this
Hi Amuthan, which version of java you are using. I installed both 1.8 and 15 but below statement Objects.isNull(key) throwing an error "The method isNull(objects) is undefined for the type Objects". Then i made the changes to pom to compile with 15 with below setting for both 1.8 T 15 & none worked.
Got much Clarity on Static Block Usage.. Thanks Amuthan
Very useful. Got good clarity on property file nand static block usage
Best video on youtube
Hi Amuthan, thanks for the video. It's too good, Just worth it.
I have one doubt, how are we achieving singleton design pattern in our framework?
@@gauravvarma6483 you dont gave to force fit an design pattern
Amuthan Bro I think I spot Right place at right time,can u please speed up the series to post videos on daily basis :)
I am trying my best to post videos as much as possible. Thank you for your patience and understanding.
Hi, When to use HashMap and when to use hashtable in framework . Both are based on key-value concept .
How to change the name of property file at run time in static block?
Then you should consider using owner library. That is better way of dealing with property files
Below is another way to create the HashMap,
for (String key : properties.stringPropertyNames()) {
propertiesMap.put(key, properties.getProperty(key));
}
Hey amuthan, why I need to create static block when I can also declare Properties file object in my constructor as well
Constructors are meant for instantiating instance members and static blocks helps to initialise static data members.
It is also termed as eager initialisation and we can be sure that the data from property file will definitely be available for us to use.
You can do that without static blocks using methods but what if there is an unhandled exception before calling method.
Your entire test suite will fail because of NPE. The cause will be due to the property values are not read.
@@TestingMiniBytes Good man, thanks for sharing
can I also make the private static Properties property = new Properties(); as private static final Properties property = new Properties();?
Amuthan Bro,if we have more than 1 Properties files ,it wouldnt help na in single static blocks, we have to create another static block, am i right?? please help me out on this
You can have it in the same static block. You can use another one too. It is entirely the way you code. There is no impact to the performance as such.
But I would advice to limit the number of property files.
Hi bro
Got to learn lot from your framework tutorial, can you please share the git link for our reference.
Thanks in advance
github.com/amuthansakthivel/SeleniumAutomationFramework_UA-cam
Amuthan have we solved the issue that we got for the feature file ? The null pointer?
We are not using any feature file in our framework.
@@TestingMiniBytes sorry my bad I was referring to the property file .
@@TestingMiniBytes got it amuthan , thanks
Hi, I am getting error at vidoe time :15:25, ConfigMap.put and the error is:The method put(String, DocFlavor.STRING) in the type HashMap is not applicable for the arguments (String, String) , please help me to fix this
I got the issue brother thanks.
Hi Amuthan, which version of java you are using. I installed both 1.8 and 15 but below statement Objects.isNull(key) throwing an error "The method isNull(objects) is undefined for the type Objects".
Then i made the changes to pom to compile with 15 with below setting for both 1.8 T 15 & none worked.
org.apache.maven.plugins
maven-compiler-plugin
3.2
15
15
So how to correct this issue.
What is the package you are importing. There can be classes from other dependencies. Try to use the one from java
Static block initialise only once when class is loaded .