Thank you sir for detail explanation . Please keep posted more videos related framework with various design principles. Which design principles used in this framework?
Why we need property file when we already have FrameWork constants? I didn't understand this part of the video. What i think is we can achive our requirement using both property file and framewok constants, they both do the same job.
Your understanding is correct. Eventhough you can achieve in both ways. Keep parameters that needs to be changed by manual testers or product owners in property files. Example like URL - Manual testers can change to different environment easily Keep constants that does not require manual testers intervention in framework constants. Example : timeouts =10, excelpath
Hey why did u remove private static WebDriver driver at 5:23?And made that normal WebDriver?The reason we are using threadLocal because we have static WebDriver?
If you want you can keep it there. ThreadLocal gives you the freedom to use the threads without any issues. If you want to keep it static class variable, you can still keep it. I dont need that to be static class variable after introducing ThreadLocal because i am not accessing it after instantiating it. If i dont use a threadlocal,whenever there are multiple threads trying to read and write on same static variable we ll face thread safety issues. After thread local introduction you dont have to worry about that.
Thanks Amuthan, thanks for the video. In general the property file should be kept within the project directory or out side? I am asking this because if any other team like manual test/BA or PO wants to update the file to run the test they have to do the project setup or they will update the file using a github link. Just wanted to know what is the industry general practice. Regards, Avik
Why they have to do the project setup and all? They can have the project folder in their machine. They can alter the file and push it to github and trigger the test via jenkins. Or you can just give them a batch file which contains mvn clean test which can do the job. Mutliple ways available!! Find the once suits you the best.
@@TestingMiniBytes Thank you so much Amuthan, whenever you get time please teach us these processes as well in the future. Appreciate you help. Regards, Avik
We are not changing the value or state when reading from property file. Each thread goes and just fetches the value and most importantly no thread is mutating the objects.
Hi, Not sure why, but when I was trying to use the key which does not exist in Properties file, the Exception is not being printed. I was using this way. DriverManager.getDriver().get(ReadPropertyFile.getValue("URL")); // where property is url=mytesturl.com When I am trying to print the path, I see some as '/' and some as '\' I still see the NullPointerException as follows java.lang.NullPointerException: null value in entry: url=null at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32) at com.google.common.collect.SingletonImmutableBiMap.(SingletonImmutableBiMap.java:42) at com.google.common.collect.ImmutableBiMap.of(ImmutableBiMap.java:72) at com.google.common.collect.ImmutableMap.of(ImmutableMap.java:124) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277) at com.tmb.driver.Driver.initDriver(Driver.java:31) at com.tmb.tests.BaseTest.setUp(BaseTest.java:15) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132) at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61) at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:366) at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:320) at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:701) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527) at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174) at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Hi Amuthan, two questions 1)we could have avoided the NPE using 3 threads instead of 2. I have used 4 test methods and 4 threads in testng xml and it was running fine. I guess the problem starts when we have less thread counts and more test methods. Can you elaborate on this? (2) We are calling unload method after every tc, then shouldn't the driver also go back to null state because unload should remove driver from stack memory and when it is removed, driver should become null. Here dr actually references driver (we are setting the value of dr to driver using set method). Can u please explain this two?
@@sushanttavrawala8394 github.com/amuthansakthivel/AmazonAssignment/blob/master/AmazonAssignment/src/main/java/com/amazon/utils/JsonParser.java See if this helps
It still fails for me with the if condition, if i run the tests on their own they work . But parallely I still get NPE and failures even if thread count >2 (I have 2 test cases in Login and 1 in HomePage)
If you are confused earlier, you will be you bare finished this part 5 and in part 6 was expecting to continue from part 5 it's completely something different. You more time talking than coding, it will be great to share your code in GitHub
Also by keeping static WebDriver driver; and if(Objects.isNull(DriverManager.getDriver())) We are getting our output. so why u change Global static WebDriver driver to local WebDriver driver = new ChromeDriver();? Also ,Which of the two approach is good ?
Just a memory management. Your local reference variables will be removed as soon as the method calls end because they are stored in thread stack memory. The object created in the heap have no reference variable and hence will be garbage collected. If you have it as static class variable both object and variable will reside in heap till the end of program. Again this is not a big issue. But when we can optimise we should.
Finding too difficult to understand especially get driver and set driver but will continue watching the series. Thanks for the good work.
you are clearing the doubts with your topics, even before asking
Very nicely explained
Thank you sir for detail explanation .
Please keep posted more videos related framework with various design principles.
Which design principles used in this framework?
Why we need property file when we already have FrameWork constants? I didn't understand this part of the video. What i think is we can achive our requirement using both property file and framewok constants, they both do the same job.
Your understanding is correct. Eventhough you can achieve in both ways. Keep parameters that needs to be changed by manual testers or product owners in property files. Example like URL - Manual testers can change to different environment easily
Keep constants that does not require manual testers intervention in framework constants. Example : timeouts =10, excelpath
5:20 driver should be set null and only create local variable inside initmethod
Hey why did u remove private static WebDriver driver at 5:23?And made that normal WebDriver?The reason we are using threadLocal because we have static WebDriver?
If you want you can keep it there. ThreadLocal gives you the freedom to use the threads without any issues. If you want to keep it static class variable, you can still keep it.
I dont need that to be static class variable after introducing ThreadLocal because i am not accessing it after instantiating it.
If i dont use a threadlocal,whenever there are multiple threads trying to read and write on same static variable we ll face thread safety issues.
After thread local introduction you dont have to worry about that.
Thanks Amuthan, thanks for the video. In general the property file should be kept within the project directory or out side? I am asking this because if any other team like manual test/BA or PO wants to update the file to run the test they have to do the project setup or they will update the file using a github link. Just wanted to know what is the industry general practice.
Regards,
Avik
Why they have to do the project setup and all? They can have the project folder in their machine. They can alter the file and push it to github and trigger the test via jenkins.
Or you can just give them a batch file which contains mvn clean test which can do the job.
Mutliple ways available!! Find the once suits you the best.
@@TestingMiniBytes Thank you so much Amuthan, whenever you get time please teach us these processes as well in the future. Appreciate you help.
Regards,
Avik
@@avikroychoudhury3858 Definitely will do that !!
why we dont use threadlocal variable in properties file to keep it thread safe...if it safe to use it like this
We are not changing the value or state when reading from property file. Each thread goes and just fetches the value and most importantly no thread is mutating the objects.
Hi,
Not sure why, but when I was trying to use the key which does not exist in Properties file, the Exception is not being printed.
I was using this way.
DriverManager.getDriver().get(ReadPropertyFile.getValue("URL")); // where property is url=mytesturl.com
When I am trying to print the path, I see some as '/' and some as '\'
I still see the NullPointerException as follows
java.lang.NullPointerException: null value in entry: url=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32)
at com.google.common.collect.SingletonImmutableBiMap.(SingletonImmutableBiMap.java:42)
at com.google.common.collect.ImmutableBiMap.of(ImmutableBiMap.java:72)
at com.google.common.collect.ImmutableMap.of(ImmutableMap.java:124)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277)
at com.tmb.driver.Driver.initDriver(Driver.java:31)
at com.tmb.tests.BaseTest.setUp(BaseTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:366)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:320)
at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:701)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
url is case sensitive. Could you please use accordingly.
Hi Amuthan, two questions 1)we could have avoided the NPE using 3 threads instead of 2. I have used 4 test methods and 4 threads in testng xml and it was running fine. I guess the problem starts when we have less thread counts and more test methods. Can you elaborate on this? (2) We are calling unload method after every tc, then shouldn't the driver also go back to null state because unload should remove driver from stack memory and when it is removed, driver should become null. Here dr actually references driver (we are setting the value of dr to driver using set method). Can u please explain this two?
In a real world the test count always will be greater.
@@TestingMiniBytes thanks. Can u also explain point number 2?
Yes it should go back to initial state and not null depending on Threadlocal initial value.
Hi can you please make the same with reading json file and fetch the value from json
Okay sure. The concept remains the same. You can use jackson object mapper to read the value and store it in map.
@@TestingMiniBytes thanks for the response. I am just struggling to get the value from the object to send keys.
@@sushanttavrawala8394 github.com/amuthansakthivel/AmazonAssignment/blob/master/AmazonAssignment/src/main/java/com/amazon/utils/JsonParser.java
See if this helps
@@TestingMiniBytes Thank you very much bro. It worked like a pro. Really appriciate all your help.
It still fails for me with the if condition, if i run the tests on their own they work . But parallely I still get NPE and failures even if thread count >2 (I have 2 test cases in Login and 1 in HomePage)
Please watch next videos. It will help to answer your question
@@TestingMiniBytes Thanks for your reply. Yes for now I have stopped running it parallelly, and checking next vids
If you are confused earlier, you will be you bare finished this part 5 and in part 6 was expecting to continue from part 5 it's completely something different. You more time talking than coding, it will be great to share your code in GitHub
Amuthan Sakthivel Github - selenium UA-cam project
Adichi norukuringa!
Nandrigal Mohan !!
Also by keeping static WebDriver driver; and
if(Objects.isNull(DriverManager.getDriver()))
We are getting our output.
so why u change Global static WebDriver driver to local WebDriver driver = new ChromeDriver();?
Also ,Which of the two approach is good ?
Just a memory management. Your local reference variables will be removed as soon as the method calls end because they are stored in thread stack memory.
The object created in the heap have no reference variable and hence will be garbage collected.
If you have it as static class variable both object and variable will reside in heap till the end of program. Again this is not a big issue.
But when we can optimise we should.