Raghav Sir you are best in teaching and explaining things step by step. The name of your Channel "Automation Step by Step" is absolutely sync with your teaching style .You are gem.
@@RaghavPal yeah i had an interview today and had to explain properties files and Excel file .. thank you for the valuable information.. keep doing more.. May God bless you.🥰
@Automation Step by Step Hello and thank you for all your tutos. I have a question : What do you think about ResourceBundle class to get the data of properties file? what is the difference between ResourceBundle class and Properties class. Thank you bro
Hi Jean, The ResourceBundle class is a powerful and convenient way to retrieve localized resources and data from properties files in Java. It provides a standard way to handle multiple locales and is highly flexible and extensible In comparison to the Properties class, which is also used for handling properties files in Java, the ResourceBundle class provides a more robust and scalable solution. While the Properties class is simple and easy to use for smaller projects, it becomes more difficult to maintain when working with larger applications that require multiple languages or locales. One of the key differences between the two classes is that ResourceBundle is designed to handle localization by allowing you to specify multiple versions of the same properties file for different languages or regions. This is done by creating separate properties files for each language and naming them accordingly, such as messages_en.properties for English or messages_fr.properties for French.
Sorry to be offtopic but does anyone know of a method to get back into an instagram account..? I somehow forgot the password. I would love any tricks you can give me!
@Krew Ashton i really appreciate your reply. I found the site through google and Im in the hacking process now. Seems to take a while so I will get back to you later with my results.
Hi Sumana, your code. If the properties file is intended to be a configuration file, where you store values that control the behavior of your tests, then it should be kept under the src/test/resources directory. This is because resources under this directory will be automatically included in the classpath of your tests, making it easy to read the properties file from your test code On the other hand, if the properties file is intended to be a utility file, where you define constants or helper methods that will be used by your test code, then it should be kept under the src/test/java directory, along with your other test code. This is because the properties file is part of your test code, and should be packaged and compiled with your test classes In general, it is a good practice to keep your configuration files separate from your test code, so that they can be easily updated without requiring changes to your test code
@@RaghavPal in getProperties method u have used "className.browserName=browser". where we have to pass the browser name. So if there are multiple classes then do we have to add all those classes in getProperties method?
I believe you need to get the values from prop file in multiple classes, So you can create one class with a constructor where you set the properties file and then in each of the class create an object of this class which will always call the constructor and then you can use the properties file values
Such an awesome session!! In this session you have shown how to derive data for one field(browser) , how can I derive the data for different fields eg. url, username , password etc. if i defined in the .properties files. Basically I want to know whether is it possible to parameterize the methods for .properties files if yes means, can you help me on this?
Hello Sir In my project they are asking not to use application url ,crdentials in properties file...while integration with jenkins ...what are alternative options available ? Please help me sir..
Excellent explanation. when i am trying my own i cannot call TestNG_Demo class in propertiesFile class. (ie demo class is one package and propertiesFile class is in another package ) should i need to add any dependencies if i am looking just this session.
thank you sir but i could not import the class too. as TestNG_demo class is in src/test/java and PropertiesFile class is in src/main/java and i am trying to write TestNG.browserName=browser; in Properties class and i couldnot....
Hello, I would like to read and write back to the same properties file throughout several test cases with getProperty/setProperty method. The configuration is in the Base class. The reading part works fine, however, it does not write back. What could be the reason?
Hi Rahav, I am having two cases, i want to use output of the 1st case in case2, for this I have stored the output of the case1 in some property file called x.properties. So Now i am running the my class file, case1 is executed successfully and the o/p is stored in x.properties, but the same output is passed as "null" for case2. But if I run the two cases individually, getting the value of the case1. Note : i am using the @test for the both cases and executing. Can you please guide me how to resolve this issue
Hi Raghav, i have doubt,y we have write in main/test/java. why we can't write in main/resources.. can you tell me,what we have to in the main/resources and main/test...sometimes you use main/resources in log4j..i am getting confusion..
Hi Vijay, usually the files/resources related to tests go in main/test/java folder, this is helpful if effective organisation. Can check this dzone.com/articles/how-to-organize-resource-files-for-tests-using-mav
@@RaghavPal thank you so much... I am following your automation video..you are best, you are very good in teaching and helping..again big thanks to clearing doubts..this not first time getting reply from you, for every lesson, you are giving reply to me..God bless your life fulfill with your dreams..thank you sir..
sir iam getting this error -->Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; Iam not using TestNG but .Can you help me with this
Hi Pranav, have you downloaded gekcko driver and have you set the path, this is shown in earlier videos of this series too System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
Hi Kumar, To feed the implicit time from a property file in Selenium Java, you can follow these steps: Create a properties file (let's say config.properties) and store the implicit time value in it. For example, you can store the implicit time as implicitTime=10 where 10 is the number of seconds. Load the properties file in your Java code using the java.util.Properties class. You can use the load() method to load the file and get the value of the implicit time property as shown below: import java.util.Properties; import java.io.FileInputStream; import java.io.IOException; public class Example { public static void main(String[] args) throws IOException { Properties prop = new Properties(); FileInputStream fis = new FileInputStream("config.properties"); prop.load(fis); // Get the implicit time value from the properties file String implicitTime = prop.getProperty("implicitTime"); // Convert the value to an integer int implicitTimeInSeconds = Integer.parseInt(implicitTime); // Use the implicit time in your Selenium code WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(implicitTimeInSeconds, TimeUnit.SECONDS); } } In this example, we are using the FileInputStream class to read the properties file and the getProperty() method to get the value of the implicitTime property. We are then converting the value to an integer and using it in the implicitlyWait() method of the WebDriver instance. Note: Make sure that the properties file is in the correct location and is accessible by your Java code.
Hi Pal I like the Video But I am having issue with The TestNg Annotations. when i write @BeforeTest annotation . import option is not showing in eclipse ide Please help me Thanks in advance Pal
Hi Yadagiri, if there is no error, than its fine. Also check the imports at the top of your class, If you have import from junit you can delete and get the import from testng.
Hi Ashvini, although I do not know exact scenario, you can get help here www.geeksforgeeks.org/java-util-properties-class-java/ www.javatpoint.com/properties-class-in-java
Raghav Sir you are best in teaching and explaining things step by step. The name of your Channel "Automation Step by Step" is absolutely sync with your teaching style .You are gem.
Thanks a lot
Awesome. Was searching so many videos..but this was the best explanation
Glad it helped Yaseer
@@RaghavPal yeah i had an interview today and had to explain properties files and Excel file .. thank you for the valuable information.. keep doing more.. May God bless you.🥰
Awesome session sir
great and clear explanation sir😊
Thanks for watching. :)
Thank you for beautiful explanation of using properties file. 👏👏
You are welcome Rajib
very much useful video for me..thank u
So nice of you Nagalakshmi
@Automation Step by Step Hello and thank you for all your tutos.
I have a question :
What do you think about ResourceBundle class to get the data of properties file?
what is the difference between ResourceBundle class and Properties class.
Thank you bro
Hi Jean,
The ResourceBundle class is a powerful and convenient way to retrieve localized resources and data from properties files in Java. It provides a standard way to handle multiple locales and is highly flexible and extensible
In comparison to the Properties class, which is also used for handling properties files in Java, the ResourceBundle class provides a more robust and scalable solution. While the Properties class is simple and easy to use for smaller projects, it becomes more difficult to maintain when working with larger applications that require multiple languages or locales.
One of the key differences between the two classes is that ResourceBundle is designed to handle localization by allowing you to specify multiple versions of the same properties file for different languages or regions. This is done by creating separate properties files for each language and naming them accordingly, such as messages_en.properties for English or messages_fr.properties for French.
@@RaghavPal Merci, Thank you
Excellent session..clear and content full explanation..
Thanks for watching Saleem
Sorry to be offtopic but does anyone know of a method to get back into an instagram account..?
I somehow forgot the password. I would love any tricks you can give me!
@Benedict Uriah Instablaster ;)
@Krew Ashton i really appreciate your reply. I found the site through google and Im in the hacking process now.
Seems to take a while so I will get back to you later with my results.
@Krew Ashton It worked and I actually got access to my account again. I am so happy:D
Thanks so much, you saved my ass :D
Sir very nice explanation thanks
Most welcome Ankit
awesome session Sir ☺️
Thanks a ton
Good explanation ragahv..thanks for video
You're welcome Nirmala
Hi Raghav, which is best place to keep properties file under src/test/resources or src/test/java?
Hi Sumana,
your code.
If the properties file is intended to be a configuration file, where you store values that control the behavior of your tests, then it should be kept under the src/test/resources directory. This is because resources under this directory will be automatically included in the classpath of your tests, making it easy to read the properties file from your test code
On the other hand, if the properties file is intended to be a utility file, where you define constants or helper methods that will be used by your test code, then it should be kept under the src/test/java directory, along with your other test code. This is because the properties file is part of your test code, and should be packaged and compiled with your test classes
In general, it is a good practice to keep your configuration files separate from your test code, so that they can be easily updated without requiring changes to your test code
Thank you
Most welcome
Hi Raghav,one quick question.Why properties.load() call is not needed for OutputStrem class or when you writing something on the the properties file?
Hi Nihar, that is needed to read properties file
Awesomeee
Thanks
Sir..here we have used property file concept....also we can derive our data from Excel through Apache poi...So which approach we used nowadays??
For some limited properties, you can use a property file created within the project. Else can go with Excel for large and dynamic values
@@RaghavPal ok thanks sir
Awesome
Thanks Ranga
what if there are multiple classes then how to access properties file? as propertiesfile class is using the class where browser is needed
.
You can create a separate instance of properties file, make it global and then you can call it from any class
@@RaghavPal in getProperties method u have used "className.browserName=browser". where we have to pass the browser name. So if there are multiple classes then do we have to add all those classes in getProperties method?
I believe you need to get the values from prop file in multiple classes, So you can create one class with a constructor where you set the properties file and then in each of the class create an object of this class which will always call the constructor and then you can use the properties file values
@@RaghavPal Thanks a lot for your help and for the tutorials. Every tutorial is very helpful and well explained. 🙂
Sir ,how to add more properties like URL,username,password to the properties file.
Hi Pranav, can add and use the same way as shown, just try and can also check some online examples
Such an awesome session!!
In this session you have shown how to derive data for one field(browser) , how can I derive the data for different fields eg. url, username , password etc. if i defined in the .properties files. Basically I want to know whether is it possible to parameterize the methods for .properties files if yes means, can you help me on this?
Hi Radha, the process should be the same for any parameter, you can try and let me know if you face any issues
Hello Sir
In my project they are asking not to use application url ,crdentials in properties file...while integration with jenkins ...what are alternative options available ?
Please help me sir..
Hi Archana,
Can keep them as parameters in a jenkins job, Check parameterized job video in Jenkins playlist
Excellent explanation. when i am trying my own i cannot call TestNG_Demo class in propertiesFile class. (ie demo class is one package and propertiesFile class is in another package ) should i need to add any dependencies if i am looking just this session.
Hi Shavda, you may try importing the class
thank you sir but i could not import the class too. as TestNG_demo class is in
src/test/java and PropertiesFile class is in src/main/java and i am trying to write TestNG.browserName=browser; in Properties class and i couldnot....
Hi Shavda, can you check the complete setup again and compare with the videos, I believe something is missed
Hello, I would like to read and write back to the same properties file throughout several test cases with getProperty/setProperty method. The configuration is in the Base class. The reading part works fine, however, it does not write back. What could be the reason?
Hi, will need to check the code and logs
Hi Rahav, I am having two cases, i want to use output of the 1st case in case2, for this I have stored the output of the case1 in some property file called x.properties. So Now i am running the my class file, case1 is executed successfully and the o/p is stored in x.properties, but the same output is passed as "null" for case2.
But if I run the two cases individually, getting the value of the case1.
Note : i am using the @test for the both cases and executing.
Can you please guide me how to resolve this issue
Hi Khadar, will have to see your project and code.
Hi Raghav,
i have doubt,y we have write in main/test/java.
why we can't write in main/resources..
can you tell me,what we have to in the main/resources and main/test...sometimes you use main/resources in log4j..i am getting confusion..
Hi Vijay, usually the files/resources related to tests go in main/test/java folder, this is helpful if effective organisation. Can check this dzone.com/articles/how-to-organize-resource-files-for-tests-using-mav
@@RaghavPal thank you so much...
I am following your automation video..you are best, you are very good in teaching and helping..again big thanks to clearing doubts..this not first time getting reply from you, for every lesson, you are giving reply to me..God bless your life fulfill with your dreams..thank you sir..
thanks for the kind words Madhavi
can we use one class of propertiesfile for multiple classes?
Yes we can Shubham
sir shall we have git hub or any link to go through the code you wrote
can check here github.com/Raghav-Pal/SeleniumJavaFramework1
sir iam getting this error -->Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property;
Iam not using TestNG but .Can you help me with this
Hi Pranav, have you downloaded gekcko driver and have you set the path, this is shown in earlier videos of this series too
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
How to feed implicit time from property file
Hi Kumar,
To feed the implicit time from a property file in Selenium Java, you can follow these steps:
Create a properties file (let's say config.properties) and store the implicit time value in it. For example, you can store the implicit time as implicitTime=10 where 10 is the number of seconds.
Load the properties file in your Java code using the java.util.Properties class. You can use the load() method to load the file and get the value of the implicit time property as shown below:
import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;
public class Example {
public static void main(String[] args) throws IOException {
Properties prop = new Properties();
FileInputStream fis = new FileInputStream("config.properties");
prop.load(fis);
// Get the implicit time value from the properties file
String implicitTime = prop.getProperty("implicitTime");
// Convert the value to an integer
int implicitTimeInSeconds = Integer.parseInt(implicitTime);
// Use the implicit time in your Selenium code
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(implicitTimeInSeconds, TimeUnit.SECONDS);
}
}
In this example, we are using the FileInputStream class to read the properties file and the getProperty() method to get the value of the implicitTime property. We are then converting the value to an integer and using it in the implicitlyWait() method of the WebDriver instance.
Note: Make sure that the properties file is in the correct location and is accessible by your Java code.
Hi Pal
I like the Video But I am having issue with The TestNg Annotations.
when i write @BeforeTest annotation . import option is not showing in eclipse ide
Please help me
Thanks in advance Pal
Hi Yadagiri, if there is no error, than its fine. Also check the imports at the top of your class, If you have import from junit you can delete and get the import from testng.
What I to do to get properties.class file in my eclipse
Hi Ashvini, although I do not know exact scenario, you can get help here
www.geeksforgeeks.org/java-util-properties-class-java/
www.javatpoint.com/properties-class-in-java
Why we use try and catch in this,?
for exception handling
@@RaghavPal how do we know that there will be exception??
Try catch block is to handle runtime exceptions in case they occur
@@RaghavPal okay
Hi sir I cannot able to get getproperties() in propertiesfile.
What is the error/logs Pavan
:)
Can you please share those slides
Faisal, you can find all the details in the notes/description, let me know if you need any other notes if missed there.