Selenium Framework - Part 8 - Property File - A mandate or Choice ?

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 35

  • @tapaskhandai
    @tapaskhandai 2 місяці тому

    Finding too difficult to understand especially get driver and set driver but will continue watching the series. Thanks for the good work.

  • @ctacts
    @ctacts 5 місяців тому +1

    you are clearing the doubts with your topics, even before asking

  • @mrindian7422
    @mrindian7422 Рік тому +1

    Very nicely explained

  • @roshnray6566
    @roshnray6566 2 роки тому +1

    Thank you sir for detail explanation .
    Please keep posted more videos related framework with various design principles.
    Which design principles used in this framework?

  • @jwalakumar9434
    @jwalakumar9434 2 роки тому +2

    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.

    • @TestingMiniBytes
      @TestingMiniBytes  2 роки тому +2

      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

  • @teo_ke
    @teo_ke Рік тому

    5:20 driver should be set null and only create local variable inside initmethod

  • @boss6378
    @boss6378 3 роки тому +1

    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?

    • @TestingMiniBytes
      @TestingMiniBytes  3 роки тому +1

      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.

  • @avikroychoudhury3858
    @avikroychoudhury3858 4 роки тому +1

    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

    • @TestingMiniBytes
      @TestingMiniBytes  4 роки тому +2

      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.

    • @avikroychoudhury3858
      @avikroychoudhury3858 4 роки тому +1

      @@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

    • @TestingMiniBytes
      @TestingMiniBytes  4 роки тому +3

      @@avikroychoudhury3858 Definitely will do that !!

  • @vhvl3888
    @vhvl3888 3 роки тому +1

    why we dont use threadlocal variable in properties file to keep it thread safe...if it safe to use it like this

    • @TestingMiniBytes
      @TestingMiniBytes  3 роки тому +1

      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.

  • @madhumuppala2274
    @madhumuppala2274 3 роки тому +1

    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)

    • @TestingMiniBytes
      @TestingMiniBytes  3 роки тому

      url is case sensitive. Could you please use accordingly.

  • @xoda345
    @xoda345 2 роки тому

    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?

    • @TestingMiniBytes
      @TestingMiniBytes  2 роки тому

      In a real world the test count always will be greater.

    • @xoda345
      @xoda345 2 роки тому

      @@TestingMiniBytes thanks. Can u also explain point number 2?

    • @TestingMiniBytes
      @TestingMiniBytes  2 роки тому +1

      Yes it should go back to initial state and not null depending on Threadlocal initial value.

  • @sushanttavrawala8394
    @sushanttavrawala8394 3 роки тому +1

    Hi can you please make the same with reading json file and fetch the value from json

    • @TestingMiniBytes
      @TestingMiniBytes  3 роки тому +1

      Okay sure. The concept remains the same. You can use jackson object mapper to read the value and store it in map.

    • @sushanttavrawala8394
      @sushanttavrawala8394 3 роки тому +1

      @@TestingMiniBytes thanks for the response. I am just struggling to get the value from the object to send keys.

    • @TestingMiniBytes
      @TestingMiniBytes  3 роки тому +1

      @@sushanttavrawala8394 github.com/amuthansakthivel/AmazonAssignment/blob/master/AmazonAssignment/src/main/java/com/amazon/utils/JsonParser.java
      See if this helps

    • @sushanttavrawala8394
      @sushanttavrawala8394 3 роки тому +1

      @@TestingMiniBytes Thank you very much bro. It worked like a pro. Really appriciate all your help.

  • @vidhya821
    @vidhya821 2 роки тому

    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)

    • @TestingMiniBytes
      @TestingMiniBytes  2 роки тому +1

      Please watch next videos. It will help to answer your question

    • @vidhya821
      @vidhya821 2 роки тому

      @@TestingMiniBytes Thanks for your reply. Yes for now I have stopped running it parallelly, and checking next vids

  • @fionabruce2009
    @fionabruce2009 2 роки тому

    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

    • @TestingMiniBytes
      @TestingMiniBytes  2 роки тому

      Amuthan Sakthivel Github - selenium UA-cam project

  • @mjj3tube
    @mjj3tube 4 роки тому +1

    Adichi norukuringa!

  • @boss6378
    @boss6378 3 роки тому +1

    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 ?

    • @TestingMiniBytes
      @TestingMiniBytes  3 роки тому

      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.