P26 - Capture screenshots for only failed tests in TestNG | TestNG |

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024
  • In this video, I have explained about "How to capture screenshots for only failed tests in TestNG".
    Points covered in this video:
    1. In how many ways we can achieve this? and what are they?
    2. How to capture screenshot for a failed test in testng using listeners?
    3. How to capture screenshot for a failed test in testng using dependency injection?
    4. How to avoid the screenshots overriding?
    =======================================
    ▶️ Next Video Link: • P27 - Default reports ...
    ◀️ Previous Video Link: • P25 - TestNG Listeners...
    ↔️ TestNG Playlist Link: bit.ly/3wXyuXB
    🔗 Code used in this video: www.hyrtutoria...
    ✴ Checkout my other playlists: bit.ly/3gLIAVL
    ☕ Buy me a coffee: bit.ly/33ljBWc
    👑 Join my youtube channel to get access to perks:👇
    / @hyrtutorials
    ========================================
    ========================================
    Connect me @
    🔗 Website - www.hyrtutoria...
    🔗 Telegram - t.me/hyrtutorials
    🔗 Facebook - / hyrtutorials
    🔗 LinkedIn - / hyrtutorials
    🔗 Twitter - / hyrtutorials
    🔗 Instagram - / hyrtutorials
    ========================================
    ========================================
    🙏 Please Subscribe🔔 to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.
    #hyrtutorials #selenium #testng
    TestNG by Yadagiri Reddy

ความคิดเห็น • 99

  • @HYRTutorials
    @HYRTutorials  2 ปีที่แล้ว +2

    ↔️ TestNG Playlist Link: bit.ly/3wXyuXB
    ✴ Checkout my other playlists: bit.ly/3gLIAVL
    ☕ Buy me a coffee: bit.ly/33ljBWc

  • @ramasraju9993
    @ramasraju9993 2 ปีที่แล้ว +3

    Every class is so detailed explanation sir . Thank you very much .God bless you .

  • @raghavendrak5381
    @raghavendrak5381 3 หลายเดือนก่อน

    You are truely Gem.. Shared cent % knowledge on TestNG,,

  • @shivshankargadade4926
    @shivshankargadade4926 2 ปีที่แล้ว +1

    every class has detailed explanation thank you

  • @tulasiramsunkara
    @tulasiramsunkara 2 ปีที่แล้ว +1

    @H Y R Tutorials : Really nice explanation. I would like to provide couple of suggestions
    1. Driver should be private in BaseTest and as an instance variable in order to avoid synchronisation issue.
    2. If we use private then we need to modify the Listener class to take screenshots

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +1

      Thankyou buddy 😊
      If you mention the driver variable as private then we can't use the same in test classes buddy

    • @tulasiramsunkara
      @tulasiramsunkara 2 ปีที่แล้ว +1

      @@HYRTutorials we have to create a public getter method for driver instance.

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +3

      so again its an extra method creation.
      Thats why we can't follow one single mode as every framework is different.
      But if we learn the subject then we can apply that in any framework.

  • @bharathpybodi2842
    @bharathpybodi2842 2 หลายเดือนก่อน

    Nice Bro

  • @sayyadimam434
    @sayyadimam434 2 ปีที่แล้ว +1

    This is amazing video.Your videos are amazing beacause you tell realtime .please make video on reporting like extent report

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Thankyou bro.
      yeah sure, next week definitely

  • @thisisreallyme3130
    @thisisreallyme3130 ปีที่แล้ว +1

    screenshotting Chrome's _built-in error screens_, (like SSL errors, broken routing, etc) would have been excellent to cover here.

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      We can't screenshots of those as they are on chrome tool and the screenshots work on the application

  • @purushottamkonda5310
    @purushottamkonda5310 2 ปีที่แล้ว +1

    Thank you for such videos

  • @RamLove_99
    @RamLove_99 2 ปีที่แล้ว +1

    Super sir meru

  • @harikanthnakka2931
    @harikanthnakka2931 2 ปีที่แล้ว +1

    Thank you so much

  • @prashuvlgs
    @prashuvlgs 2 ปีที่แล้ว +1

    Reminding again next week you promised that you will make video for an extent report.

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +1

      Will try my best buddy

  • @prashuvlgs
    @prashuvlgs 2 ปีที่แล้ว +1

    In testNg also can we capture the screenshots I was not aware this.. thanks for making this video

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +1

      In testng we cant capture screenshots but we can decide when to capture the screenshots

    • @Bell4Fun
      @Bell4Fun 2 ปีที่แล้ว +1

      Cypress is better when there is need for screenshot it automatically take the screenshots

    • @prashuvlgs
      @prashuvlgs 2 ปีที่แล้ว

      @@Bell4Fun thanks. I was not aware of this before.. Cypress is programming knowledge?

  • @sainathtummari3527
    @sainathtummari3527 2 ปีที่แล้ว +1

    Nice

  • @sivayadav6718
    @sivayadav6718 ปีที่แล้ว +2

    Please brother while your writing program you can remove the console we can't see total program completely.. ❤

  • @GopiNath-iu8qe
    @GopiNath-iu8qe 2 ปีที่แล้ว +1

    How to attach the screenshot to testng report (i..e, to e-mailable report). This because explains only taking screenshot and store in local drive.......

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      We don't mostly use the TestNG default reports buddy but we use extent reports or allure reports.
      So check-out my extent reports playlist for learning more on reporting

  • @adarsh6750
    @adarsh6750 8 หลายเดือนก่อน

    Hi @HYRTutorials, I have a base testclass file in which the testcase using dataProvider which is used by a sequence of testcases, So I cannot implement nested testcases right, so I implemented each testcase in a different class file and all the testcases will be called under the basetest. But after running the testcases in report it's showing the correct screenshot incase if there is a failure but showing base testclass file as failure instead of it's respective testcase. What to do?

  • @filipjakovlevski8289
    @filipjakovlevski8289 ปีที่แล้ว +1

    In OnTestFailure method can we take screenshot of element that failed and not the screenshot of entire page?

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      With latest version of selenium you can take it buddy. But you need to pass that element information into this ontestfaioure method

  • @sk-wy6lh
    @sk-wy6lh 2 ปีที่แล้ว +1

    Hello sir you called captureScreenshot method in onTestFailure method of listner class then how you called it directly because it is not a static method

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      But we are extending the basetest class in the listener class ryt

  • @naveenkdhanush
    @naveenkdhanush 5 หลายเดือนก่อน

    Hi Sir, What is the need of checking screenshotSubFolderName == null? I understand it is for creating unique filenames. Anyway the string screenshotSubFolderName will be null all the time as we haven't declared it. What is the need here? Can you pls explain the logic!?

  • @tech_with_jatin
    @tech_with_jatin ปีที่แล้ว +1

    There is a problem with the code. the webdriver should never be static. If you make it static then you wont be able to do parallel testing.

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      Yes I agree. For that we need to handle this differently.

  • @ajsharma1752
    @ajsharma1752 ปีที่แล้ว +1

    Hi, I am getting error message - java.lang.NullPointerException (How listeners class knowns about the driver)

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      You can either inject it or get it in the way that I have shown in this video buddy

  • @charithalekkala8632
    @charithalekkala8632 ปีที่แล้ว +1

    can we use dataprovider for passing multiple data?

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      Yes buddy. That's the sole purpose of data provider

  • @pradeepbhukya6969
    @pradeepbhukya6969 2 ปีที่แล้ว +1

    Bro how to set maven path in windows system
    Try one video bro

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Please check this video buddy.
      th-cam.com/video/-6Gq_lQbR_c/w-d-xo.html

  • @anveshi2724
    @anveshi2724 ปีที่แล้ว +1

    anna, you used there xml for listener ok,
    I tried with @Listener annotation but browsers are not closing, they are continueing in the same browser

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      That's strange. Send me the screenshots on hyadagirireddytutorials@gmail.com

  • @shreyanshsingh2782
    @shreyanshsingh2782 2 ปีที่แล้ว +1

    Hi Sir,
    FileUtils.copyFile(f,new File("./Screenshots/fileName")); when I am giving like this screenshots are not getting saved, but when I changed to FileUtils.copyFile(f,new File("./Screenshots/"+fileName)); it is working why please explain

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +1

      Here filename is the variable.
      If u mention that inside the double quotes then it is considered as a text. It considers the text as "fileName". But you need the data present in fileName variable so for that you need to use in the second way.

  • @kalyanreddy4820
    @kalyanreddy4820 2 ปีที่แล้ว +1

    Sir please make capturing screen shot on data-driven framework, cucumber framework and pom framework also sir requesting you sir

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      It is same in any of those framworks buddy.
      They all use the testng and selenium only internally. so if you understand those frameworks and this concept then it is very easy to implement this in any framework

    • @kalyanreddy4820
      @kalyanreddy4820 2 ปีที่แล้ว

      @@HYRTutorials ohh is it sir

    • @kalyanreddy4820
      @kalyanreddy4820 2 ปีที่แล้ว +1

      @@HYRTutorials sir one small last and final doubt in any framework if we want to take screenshot we must add TestNg dependancy or TestNg library sir. Remaining procedure will be same sir

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      No no you got confused here buddy.
      TestNG doesn't take any screenshot.
      Selenium takes the screenshot but TestNG lets you decide when to take that screenshot using its listeners and annotations concepts

  • @prashuvlgs
    @prashuvlgs 2 ปีที่แล้ว +1

    HYR pls make video of extent report5 🙏

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว +1

      It is not going to be a single video and the first video is scheduled for tomorrow morning 11AM.

  • @sriniVasan-do3kv
    @sriniVasan-do3kv 2 ปีที่แล้ว +1

    Hi bro how you call screenshot method in listeners class without creating a object. we are extending that class but it is not a static method right if it is static means no problem we can directly call if it is not static means how we can call directly pls explain bro

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      When you introduce the inheritance concept, it is possible buddy

  • @santhoshreddy4152
    @santhoshreddy4152 6 หลายเดือนก่อน

    I follow all the steps but Unable to capture screen shot.. pls help me

  • @sumitmitkari6087
    @sumitmitkari6087 2 ปีที่แล้ว +1

    What is mean by teardown in video

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Usually the driver closing or quitting part is called as tear down in automation industry

  • @thinkwith_shannu
    @thinkwith_shannu 2 ปีที่แล้ว +1

    Hi Sir, nenu 2 and half years development project lo work chesanu. ippudu nenu automation testing side vellalani ankntnna endhukante naku mundhu nunchi testing medha intesrest udhi, but na career starting lo developer ga vesaru, so nenu change avvadniki kudharledhu. me videos follow ayyanu. nenu tvaraga testing lo job techukovalante am cheyyali? plz give any suggestions/tips also to become effective tester?

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      That's good to know and welcome to testing buddy.
      The first thing is you need to change your perspective as you have been a developer till now.
      As a tester your main job is to break the code that is written by dev.
      Learn the testing concepts and then continue with automation tools

  • @amalraj4840
    @amalraj4840 ปีที่แล้ว +1

    Pls use try catch instead of thread.sleep()

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      The reason I have used try catch is just to show the demo only buddy

  • @anveshi2724
    @anveshi2724 ปีที่แล้ว +1

    can you plz tell what is log files?

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      Log files are used for storing any information from your application buddy

  • @PrashantPatil-rb8eq
    @PrashantPatil-rb8eq ปีที่แล้ว +1

    hello sir i have gate null pointer exception how to resolve it

    • @HYRTutorials
      @HYRTutorials  ปีที่แล้ว

      Nullpointer exception is a very common exception occurs when u r performing any operations on variables with null value

  • @sk-wy6lh
    @sk-wy6lh 2 ปีที่แล้ว +1

    So we should called it by using object isn't it

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      When we use the inheritance concept, we don't require the object creation buddy

  • @raghavendrarao5841
    @raghavendrarao5841 2 ปีที่แล้ว +1

    i want to learn cucumber perfectly can you suggest please ?

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      At the moment I don't have any videos on cucumber buddy

  • @dhanunjayae5970
    @dhanunjayae5970 2 ปีที่แล้ว

    Get time stamp method is not understandable creation of unique folders every time please explain it once

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      If you want to create new folder everytime how are you going to do that?
      For doing it we need a unique folder name right?
      So for generating that we are using timestamp here.
      Time stamp is going to be unique everytime.
      Instead of this you can use some randome number logic also but time stamp is more understandable way

  • @N.raju8247
    @N.raju8247 2 ปีที่แล้ว +1

    How to alignment in testing file what is key sir

  • @sanjaykumarmahapatra7865
    @sanjaykumarmahapatra7865 2 ปีที่แล้ว +1

    when i tried with this code for me its showing Filenotfoundexception

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Send me screenshot and script on hyadagirireddytutorials@gmail.com

    • @N.raju8247
      @N.raju8247 2 ปีที่แล้ว

      Same bro

  • @hariprasad1023
    @hariprasad1023 2 ปีที่แล้ว +1

    How many classes are remaining in testing?

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Im not exactly counting the classes buddy.
      But approximately 15+ videos are pending still.
      So on overall around 40+ videos in TestNG.

    • @Bell4Fun
      @Bell4Fun 2 ปีที่แล้ว +1

      Knowledge is not limited it is ocean bro

    • @praveenkumar-ub9hv
      @praveenkumar-ub9hv 2 ปีที่แล้ว +1

      @@HYRTutorials please upload it as faster u can anna please 🙂

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Sure buddy

  • @santhoshp6764
    @santhoshp6764 6 หลายเดือนก่อน

    Hi @HYRTutorials i tried this code, but screenshot is not captured. pls help me out

  • @ramyavasagar6616
    @ramyavasagar6616 9 หลายเดือนก่อน

    I tried the same but I'm getting driver as null ..please help

    • @santhoshvennampally9137
      @santhoshvennampally9137 2 หลายเดือนก่อน

      I think you dint mention "public static" before calling webdriver

  • @gowthamv4722
    @gowthamv4722 2 ปีที่แล้ว

    Using Listeners To capture both pass and fail test cases? Give suggestion.

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      I have already explained in the video right buddy

  • @kareemcurwen891
    @kareemcurwen891 2 ปีที่แล้ว +1

    ? p͎r͎o͎m͎o͎s͎m͎

  • @Bell4Fun
    @Bell4Fun 2 ปีที่แล้ว +1

    क्या आप के पास हिंदी भाषी क्षेत्र के लिए कुछ नहीं है।

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Nope buddy.
      I know Hindi but not to the level of teaching

  • @kjayanth446
    @kjayanth446 2 ปีที่แล้ว +1

    Hi ,
    I'm getting this exception "Cannot invoke "org.openqa.selenium.TakesScreenshot.getScreenshotAs(org.openqa.selenium.OutputType)" because "takesScreenshot" is null" , when I'm trying to take a screenshots for failed cases and using ITest Listener. Hope you drop the solution here.

    • @HYRTutorials
      @HYRTutorials  2 ปีที่แล้ว

      Ikkada somehow takescreenshot value bull ga undi.
      Identify the cause for that buddy.
      Or send me the project on hyadagirireddytutorials@gmail.com