Android apps to use in appium android test examples


Sunday, September 17, 2017

Capture Screenshot On Failure Or Pass - WebDriver Data Driven Framework

In our WebDriver information driven framework creation, We accept Implemented calc software tests In all calc examination cases of WebDriver information driven framework In STEP 30. Now supposing, You wants to capture screenshot of software spider web page when your examination fails. It volition helps y'all to analyse the examination failure reason. Based on spider web page screenshot,
y'all tin easily uncovering out the examination failure reason. Same way, Supposing y'all wants to capture screenshot when your examination pass. This pace volition pull y'all how to capture screenshot on examination failure or software automation examination pass.

Prerequisite : All previous information driven framework creation steps should endure Implemented. Find links of all previous steps on THIS PAGE.

What nosotros volition produce In this step
As described above, We wants to capture screenshot on software examination example neglect or examination example move past times or both. We volition Implement this functionality In such a way hence that y'all tin easily ready which screenshot y'all wants to capture. For that y'all accept to ready flags In file in addition to and then framework volition capture screenshots based on your flag choice.

How To Do It
Do y'all accept heard most testng listeners? We volition utilization testng ITestListener Interface methods onTestFailure and onTestSuccess to solve our purpose. Question Is for what these methods are?
  • onTestFailure : This method volition endure Invoked each fourth dimension a examination succeeds.
  • onTestFailure : This method volition endure Invoked each fourth dimension a examination fails.
Both these testng ITestListener Interface methods volition assist us to capture screenshots In our information driven framework.

Download Required Files
You involve novel created file for capturing screenshot on software examination failure or success. We involve to define listener In testng.xml file in addition to also y'all involve to define screenShotOnFail or screenShotOnPass or both. So y'all involve modified version of both these files too. You volition larn all these 3 files past times downloading bellow given null folder.
Extract the folder in addition to Add/Replace files equally bellow In eclipse.
  • Paste File on Package.
  • Paste File on com.stta.utility Package.
  • Paste testng.xml File on WDDF Project folder.
Your folder construction volition looks similar bellow.

If y'all opened upwards  testng.xml file, You volition come across that I accept added only about extra code In It to define listener. file contains testng listener methods in addition to captureScreenShot method to capture screenshot on move past times or failure. I accept added ii novel cardinal In testng.xml File amongst values equally bellow.

screenShotOnFail=yes screenShotOnPass=yes

  • screenShotOnFail=yes way y'all wants to capture screenshot when your examination example fails. 
  • Same way screenShotOnPass=yes volition capture screenshot when examination example pass.
  • screenShotOnFail=no means screenshot volition endure non captured fifty-fifty examination example fails.
  • screenShotOnPass=no means screenshot volition endure non captured when examination example pass.
You tin ready both these flags equally per your requirement.

Run Test And Verify Output
Run examination from "Shortcut to Run Test.bat" file. Right now screenShotOnFail and screenShotOnPass are ready to yes so It volition capture screenshots In both the cases. Means, We accept full 8 information ready lines for full iv examination cases hence It volition capture full 8 screenshots. 

When examination execution completed, Refresh "WDDF" projection folder. You volition come across that It has created novel folder "screenshots" amongst 2 sub folders "Failures" in addition to "Success". Expand all those folders. Our 2 tests are failed in addition to half dozen tests are move past times hence y'all volition uncovering full 2 .png files nether "Failures" folder in addition to half dozen .png files nether "Success" folder equally shown In bellow given Image.

Now y'all tin opened upwards all those files to analyse results. Basically screenshots are required alone for failure weather to come across the software spider web page status when examination was failed.

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM

No comments:

Post a Comment