How to take screenshot of every page in TESTNG.

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to take screenshot of every page in TESTNG.

Kritika Gupta
I have written a code to take screenshot and to store the screenshots based on the test case name.
I am calling this function before navigating to next page or before clicking on next button or submit or anyother button.

I am using hybrid structure and converting my project to TESTNG.

Is there any way or any annotation which will call screenshot function after each step in my method.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to take screenshot of every page in TESTNG.

Krishnan Mahadevan
No. I dont think there is anything like that which you can use out of the box in TestNG.

Reason is because, TestNG test method is just a bunch of java statements bundled together with one or more assertions.

TestNG is aware of only the method, but what happens within the method is beyond TestNG's reach.

If you would like to just build this capability, you need to be leveraging something like an EventFiringWebDriver (or) perhaps resort to the command executor approach.

You can find more details about it in my blog post here : https://rationaleemotions.wordpress.com/2015/04/18/eavesdropping-into-webdriver/

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Mon, Oct 30, 2017 at 4:05 PM, Kritika Gupta <[hidden email]> wrote:
I have written a code to take screenshot and to store the screenshots based on the test case name.
I am calling this function before navigating to next page or before clicking on next button or submit or anyother button.

I am using hybrid structure and converting my project to TESTNG.

Is there any way or any annotation which will call screenshot function after each step in my method.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to take screenshot of every page in TESTNG.

Kritika Gupta
Thanks for your reply,

I am taking screenshot in every 10 sec and I want to implement this code with my main @Test using parallel testing. Also I am keeping screenshots based on testcase name folder. Test case name I am getting from data provider.

so finally I should be having 2 @Test , both needs dataprovider to get the testcasename.
Can you please guide me if my approach is Ok?
Or Is there anyway IF I can set the timer when to start the 2nd @Test so that it will take the screenshot only after login to the app?
Passing data provider to both @Test , will it cause running data provider twice.

Kindly advise.

Below is my code: 

@Parameters({"Environment"})

@Test(dataProvider = "returnTestcaseRow", priority = 1)

public static void main(String Environment, String flag, String TestCaseName)

{

try {

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");

EATradeCreation.CreationEATrade(Environment, flag, TestCaseName);

  } catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

@Test

public static void callScreen(String TestCaseName) throws Exception

{

while(true)

{

EAScreenshot.captureScreenShot(TestCaseName);

Thread.sleep(10000);

}

}

@DataProvider(name = "returnTestcaseRow")

public Object[][] EOT_testcasedata() throws Exception{

Object[][] testObjArray;

testObjArray = EOTdata.getTableArray(

"D:\\Automation\\EAAUTO\\src\\testData\\EOT_TestData_Updated.xlsx");

return testObjArray;



And this is my screenshot class which is taking screenshot

public class EAScreenshot {

public static void captureScreenShot(String TestCaseName) throws Exception {

Robot robot = new Robot();

BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

File dir = new File("D:\\TestResult\\"+ EOTMain.FOLDERNAME + "\\"+ TestCaseName);

dir.mkdir();

ImageIO.write(screenShot, "JPG", new File( dir + "\\"+System.currentTimeMillis()+".jpg"));

}

}






On Monday, October 30, 2017 at 4:42:41 PM UTC+5:30, Krishnan Mahadevan wrote:
No. I dont think there is anything like that which you can use out of the box in TestNG.

Reason is because, TestNG test method is just a bunch of java statements bundled together with one or more assertions.

TestNG is aware of only the method, but what happens within the method is beyond TestNG's reach.

If you would like to just build this capability, you need to be leveraging something like an EventFiringWebDriver (or) perhaps resort to the command executor approach.

You can find more details about it in my blog post here : <a onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frationaleemotions.wordpress.com%2F2015%2F04%2F18%2Feavesdropping-into-webdriver%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHuGk64cF8lGxvYfv0ignTd3BcTg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Frationaleemotions.wordpress.com%2F2015%2F04%2F18%2Feavesdropping-into-webdriver%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHuGk64cF8lGxvYfv0ignTd3BcTg&#39;;return true;" href="https://rationaleemotions.wordpress.com/2015/04/18/eavesdropping-into-webdriver/" target="_blank" rel="nofollow">https://rationaleemotions.wordpress.com/2015/04/18/eavesdropping-into-webdriver/

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow">http://rationaleemotions.wordpress.com/

On Mon, Oct 30, 2017 at 4:05 PM, Kritika Gupta <<a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="NPvSM_4QBgAJ">kritika...@...> wrote:
I have written a code to take screenshot and to store the screenshots based on the test case name.
I am calling this function before navigating to next page or before clicking on next button or submit or anyother button.

I am using hybrid structure and converting my project to TESTNG.

Is there any way or any annotation which will call screenshot function after each step in my method.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="NPvSM_4QBgAJ">testng-users...@googlegroups.com.
To post to this group, send email to <a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="NPvSM_4QBgAJ">testng...@....
Visit this group at <a onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow">https://groups.google.com/group/testng-users.
For more options, visit <a onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" href="https://groups.google.com/d/optout" target="_blank" rel="nofollow">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to take screenshot of every page in TESTNG.

Krishnan Mahadevan

What do you intend to achieve with taking screenshots based on timers ? What is the usecase that you are trying to solve ?

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Kritika Gupta <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, November 1, 2017 at 3:31 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to take screenshot of every page in TESTNG.

 

Thanks for your reply,

 

I am taking screenshot in every 10 sec and I want to implement this code with my main @Test using parallel testing. Also I am keeping screenshots based on testcase name folder. Test case name I am getting from data provider.

 

so finally I should be having 2 @Test , both needs dataprovider to get the testcasename.

Can you please guide me if my approach is Ok?

Or Is there anyway IF I can set the timer when to start the 2nd @Test so that it will take the screenshot only after login to the app?

Passing data provider to both @Test , will it cause running data provider twice.

 

Kindly advise.

 

Below is my code: 

 

@Parameters({"Environment"})

@Test(dataProvider = "returnTestcaseRow", priority = 1)

public static void main(String Environment, String flag, String TestCaseName)

{

try {

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");

EATradeCreation.CreationEATrade(Environment, flag, TestCaseName);

  } catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

@Test

public static void callScreen(String TestCaseName) throws Exception

{

while(true)

{

EAScreenshot.captureScreenShot(TestCaseName);

Thread.sleep(10000);

}

}

@DataProvider(name = "returnTestcaseRow")

public Object[][] EOT_testcasedata() throws Exception{

Object[][] testObjArray;

testObjArray = EOTdata.getTableArray(

"D:\\Automation\\EAAUTO\\src\\testData\\EOT_TestData_Updated.xlsx");

return testObjArray;

 

 

And this is my screenshot class which is taking screenshot

 

public class EAScreenshot {

public static void captureScreenShot(String TestCaseName) throws Exception {

Robot robot = new Robot();

BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

File dir = new File("D:\\TestResult\\"+ EOTMain.FOLDERNAME + "\\"+ TestCaseName);

dir.mkdir();

ImageIO.write(screenShot, "JPG", new File( dir + "\\"+System.currentTimeMillis()+".jpg"));

}

}

 

 

 

 


On Monday, October 30, 2017 at 4:42:41 PM UTC+5:30, Krishnan Mahadevan wrote:

No. I dont think there is anything like that which you can use out of the box in TestNG.

 

Reason is because, TestNG test method is just a bunch of java statements bundled together with one or more assertions.

 

TestNG is aware of only the method, but what happens within the method is beyond TestNG's reach.

 

If you would like to just build this capability, you need to be leveraging something like an EventFiringWebDriver (or) perhaps resort to the command executor approach.

 

You can find more details about it in my blog post here : https://rationaleemotions.wordpress.com/2015/04/18/eavesdropping-into-webdriver/


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

On Mon, Oct 30, 2017 at 4:05 PM, Kritika Gupta <<a href="javascript:" target="_blank">kritika...@...> wrote:

I have written a code to take screenshot and to store the screenshots based on the test case name.

I am calling this function before navigating to next page or before clicking on next button or submit or anyother button.

 

I am using hybrid structure and converting my project to TESTNG.

 

Is there any way or any annotation which will call screenshot function after each step in my method.

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank">testng-users...@....
To post to this group, send email to <a href="javascript:" target="_blank">testng...@....
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to take screenshot of every page in TESTNG.

Kritika Gupta
I want to take screenshots in every 10 secs only once my application is logged in , and want  to store the screenshots based on test case name. I am getting test case name from excel sheet using dataprovider.

So in my main testng class - there are 2 @test , 1 is to run the test case based on the testcase name and other is to take screenshot and both needs dataprovider parameter testcasename.

Is it possible to implement.





On Thu, Nov 2, 2017 at 9:54 AM, Krishnan Mahadevan <[hidden email]> wrote:

What do you intend to achieve with taking screenshots based on timers ? What is the usecase that you are trying to solve ?

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Kritika Gupta <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, November 1, 2017 at 3:31 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to take screenshot of every page in TESTNG.

 

Thanks for your reply,

 

I am taking screenshot in every 10 sec and I want to implement this code with my main @Test using parallel testing. Also I am keeping screenshots based on testcase name folder. Test case name I am getting from data provider.

 

so finally I should be having 2 @Test , both needs dataprovider to get the testcasename.

Can you please guide me if my approach is Ok?

Or Is there anyway IF I can set the timer when to start the 2nd @Test so that it will take the screenshot only after login to the app?

Passing data provider to both @Test , will it cause running data provider twice.

 

Kindly advise.

 

Below is my code: 

 

@Parameters({"Environment"})

@Test(dataProvider = "returnTestcaseRow", priority = 1)

public static void main(String Environment, String flag, String TestCaseName)

{

try {

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");

EATradeCreation.CreationEATrade(Environment, flag, TestCaseName);

  } catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

@Test

public static void callScreen(String TestCaseName) throws Exception

{

while(true)

{

EAScreenshot.captureScreenShot(TestCaseName);

Thread.sleep(10000);

}

}

@DataProvider(name = "returnTestcaseRow")

public Object[][] EOT_testcasedata() throws Exception{

Object[][] testObjArray;

testObjArray = EOTdata.getTableArray(

"D:\\Automation\\EAAUTO\\src\\testData\\EOT_TestData_Updated.xlsx");

return testObjArray;

 

 

And this is my screenshot class which is taking screenshot

 

public class EAScreenshot {

public static void captureScreenShot(String TestCaseName) throws Exception {

Robot robot = new Robot();

BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

File dir = new File("D:\\TestResult\\"+ EOTMain.FOLDERNAME + "\\"+ TestCaseName);

dir.mkdir();

ImageIO.write(screenShot, "JPG", new File( dir + "\\"+System.currentTimeMillis()+".jpg"));

}

}

 

 

 

 


On Monday, October 30, 2017 at 4:42:41 PM UTC+5:30, Krishnan Mahadevan wrote:

No. I dont think there is anything like that which you can use out of the box in TestNG.

 

Reason is because, TestNG test method is just a bunch of java statements bundled together with one or more assertions.

 

TestNG is aware of only the method, but what happens within the method is beyond TestNG's reach.

 

If you would like to just build this capability, you need to be leveraging something like an EventFiringWebDriver (or) perhaps resort to the command executor approach.

 

You can find more details about it in my blog post here : https://rationaleemotions.wordpress.com/2015/04/18/eavesdropping-into-webdriver/


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

On Mon, Oct 30, 2017 at 4:05 PM, Kritika Gupta <[hidden email]> wrote:

I have written a code to take screenshot and to store the screenshots based on the test case name.

I am calling this function before navigating to next page or before clicking on next button or submit or anyother button.

 

I am using hybrid structure and converting my project to TESTNG.

 

Is there any way or any annotation which will call screenshot function after each step in my method.

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/qE-aOWTueSk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.



--
--
Kritika Gupta

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to take screenshot of every page in TESTNG.

Todd Bradley-2
Of course it's possible to implement - anything is possible in software - but it sounds like a terrible design. That's probably why Krishnan was asking what you're really trying to achieve. 

Do you run tests in parallel threads? If so, do you expect each thread to have a screen shot of whatever it's doing?

What do you want to happen if, when it's time for the screenshot to happen, TestNG is running a configuration method and not a test method? For example, what if it's executing a @BeforeMethod method?

What do you want to happen if a test method takes less than 10 seconds to execute? Is it OK to have no screenshot of that test?

The general approach to doing this is going to have nothing to do with TestNG, once again. You'll need to spawn off and manage a separate thread with a timer that takes the screenshot every 10 seconds, and your test will have to share the name of the currently executing test with that screenshot thread. How you do all that is a great topic for an intermediate Java training, not TestNG.


Cheers,
Todd.



On Wed, Nov 1, 2017 at 10:51 PM, Kritika Gupta <[hidden email]> wrote:
I want to take screenshots in every 10 secs only once my application is logged in , and want  to store the screenshots based on test case name. I am getting test case name from excel sheet using dataprovider.

So in my main testng class - there are 2 @test , 1 is to run the test case based on the testcase name and other is to take screenshot and both needs dataprovider parameter testcasename.

Is it possible to implement.





On Thu, Nov 2, 2017 at 9:54 AM, Krishnan Mahadevan <[hidden email]> wrote:

What do you intend to achieve with taking screenshots based on timers ? What is the usecase that you are trying to solve ?

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of Kritika Gupta <[hidden email]>
Reply-To: <[hidden email]>
Date: Wednesday, November 1, 2017 at 3:31 PM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to take screenshot of every page in TESTNG.

 

Thanks for your reply,

 

I am taking screenshot in every 10 sec and I want to implement this code with my main @Test using parallel testing. Also I am keeping screenshots based on testcase name folder. Test case name I am getting from data provider.

 

so finally I should be having 2 @Test , both needs dataprovider to get the testcasename.

Can you please guide me if my approach is Ok?

Or Is there anyway IF I can set the timer when to start the 2nd @Test so that it will take the screenshot only after login to the app?

Passing data provider to both @Test , will it cause running data provider twice.

 

Kindly advise.

 

Below is my code: 

 

@Parameters({"Environment"})

@Test(dataProvider = "returnTestcaseRow", priority = 1)

public static void main(String Environment, String flag, String TestCaseName)

{

try {

System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");

EATradeCreation.CreationEATrade(Environment, flag, TestCaseName);

  } catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

@Test

public static void callScreen(String TestCaseName) throws Exception

{

while(true)

{

EAScreenshot.captureScreenShot(TestCaseName);

Thread.sleep(10000);

}

}

@DataProvider(name = "returnTestcaseRow")

public Object[][] EOT_testcasedata() throws Exception{

Object[][] testObjArray;

testObjArray = EOTdata.getTableArray(

"D:\\Automation\\EAAUTO\\src\\testData\\EOT_TestData_Updated.xlsx");

return testObjArray;

 

 

And this is my screenshot class which is taking screenshot

 

public class EAScreenshot {

public static void captureScreenShot(String TestCaseName) throws Exception {

Robot robot = new Robot();

BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));

File dir = new File("D:\\TestResult\\"+ EOTMain.FOLDERNAME + "\\"+ TestCaseName);

dir.mkdir();

ImageIO.write(screenShot, "JPG", new File( dir + "\\"+System.currentTimeMillis()+".jpg"));

}

}

 

 

 

 


On Monday, October 30, 2017 at 4:42:41 PM UTC+5:30, Krishnan Mahadevan wrote:

No. I dont think there is anything like that which you can use out of the box in TestNG.

 

Reason is because, TestNG test method is just a bunch of java statements bundled together with one or more assertions.

 

TestNG is aware of only the method, but what happens within the method is beyond TestNG's reach.

 

If you would like to just build this capability, you need to be leveraging something like an EventFiringWebDriver (or) perhaps resort to the command executor approach.

 

You can find more details about it in my blog post here : https://rationaleemotions.wordpress.com/2015/04/18/eavesdropping-into-webdriver/


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

On Mon, Oct 30, 2017 at 4:05 PM, Kritika Gupta <[hidden email]> wrote:

I have written a code to take screenshot and to store the screenshots based on the test case name.

I am calling this function before navigating to next page or before clicking on next button or submit or anyother button.

 

I am using hybrid structure and converting my project to TESTNG.

 

Is there any way or any annotation which will call screenshot function after each step in my method.

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]om.
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "testng-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/testng-users/qE-aOWTueSk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.



--
--
Kritika Gupta

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.