Non Static driver and screenshot listener in TestNG

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

Non Static driver and screenshot listener in TestNG

praveen133t
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Non Static driver and screenshot listener in TestNG

Krishnan Mahadevan
Maybe you should take a look at ThreadLocal 

On Friday, July 12, 2013, talon wrote:
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Non Static driver and screenshot listener in TestNG

praveen133t
Hi Krishnan,

I consider all your solutions in the forum as extremely useful one. If you have any implemented code I kindly request you to pls share it. I did some googling and read something about ThreadLocal. but couldn't figure out much. Pls help me. Thanks a lot!

Thanks,
Praveen


On Thu, Jul 11, 2013 at 9:29 PM, Krishnan Mahadevan <[hidden email]> wrote:
Maybe you should take a look at ThreadLocal 

On Friday, July 12, 2013, talon wrote:
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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/NFZAmNnsSP4/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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Non Static driver and screenshot listener in TestNG

Krishnan Mahadevan
This should be a good start : 



On Friday, July 12, 2013, Praveen Bhasker wrote:
Hi Krishnan,

I consider all your solutions in the forum as extremely useful one. If you have any implemented code I kindly request you to pls share it. I did some googling and read something about ThreadLocal. but couldn't figure out much. Pls help me. Thanks a lot!

Thanks,
Praveen


On Thu, Jul 11, 2013 at 9:29 PM, Krishnan Mahadevan <<a href="javascript:_e({}, &#39;cvml&#39;, &#39;krishnan.mahadevan1978@gmail.com&#39;);" target="_blank">krishnan.mahadevan1978@...> wrote:
Maybe you should take a look at ThreadLocal 

On Friday, July 12, 2013, talon wrote:
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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/NFZAmNnsSP4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Non Static driver and screenshot listener in TestNG

praveen133t
Thanks Krishnan. 

Until today I was having the driver variable as a static one so the screenshot listener worked perfectly during a failure. From today we wanted to implement parallel test execution and I faced problem due to the static driver variable. So when I made the driver as non-static screenshot listener got messed up.

So do you think implementing ThreadLocal will help me resolve both the aforementioned conditions?

Thanks,
Praveen


On Thu, Jul 11, 2013 at 10:00 PM, Krishnan Mahadevan <[hidden email]> wrote:
This should be a good start : 



On Friday, July 12, 2013, Praveen Bhasker wrote:
Hi Krishnan,

I consider all your solutions in the forum as extremely useful one. If you have any implemented code I kindly request you to pls share it. I did some googling and read something about ThreadLocal. but couldn't figure out much. Pls help me. Thanks a lot!

Thanks,
Praveen


On Thu, Jul 11, 2013 at 9:29 PM, Krishnan Mahadevan <[hidden email]> wrote:
Maybe you should take a look at ThreadLocal 

On Friday, July 12, 2013, talon wrote:
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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/NFZAmNnsSP4/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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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/NFZAmNnsSP4/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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Non Static driver and screenshot listener in TestNG

Krishnan Mahadevan
Yes it would. ThreadLocal gurantees that every thread would get its own copy of an object and there are no race conditions. 

Initialising the ThreadLocal variable can be done in beforeInvocation()

On Friday, July 12, 2013, Praveen Bhasker wrote:
Thanks Krishnan. 

Until today I was having the driver variable as a static one so the screenshot listener worked perfectly during a failure. From today we wanted to implement parallel test execution and I faced problem due to the static driver variable. So when I made the driver as non-static screenshot listener got messed up.

So do you think implementing ThreadLocal will help me resolve both the aforementioned conditions?

Thanks,
Praveen


On Thu, Jul 11, 2013 at 10:00 PM, Krishnan Mahadevan <[hidden email]> wrote:
This should be a good start : 



On Friday, July 12, 2013, Praveen Bhasker wrote:
Hi Krishnan,

I consider all your solutions in the forum as extremely useful one. If you have any implemented code I kindly request you to pls share it. I did some googling and read something about ThreadLocal. but couldn't figure out much. Pls help me. Thanks a lot!

Thanks,
Praveen


On Thu, Jul 11, 2013 at 9:29 PM, Krishnan Mahadevan <[hidden email]> wrote:
Maybe you should take a look at ThreadLocal 

On Friday, July 12, 2013, talon wrote:
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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/NFZAmNnsSP4/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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Thanks & Re


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

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Non Static driver and screenshot listener in TestNG

praveen133t
Awesome. Like always you helped me :)


On Thu, Jul 11, 2013 at 10:50 PM, Krishnan Mahadevan <[hidden email]> wrote:
Yes it would. ThreadLocal gurantees that every thread would get its own copy of an object and there are no race conditions. 

Initialising the ThreadLocal variable can be done in beforeInvocation()

On Friday, July 12, 2013, Praveen Bhasker wrote:
Thanks Krishnan. 

Until today I was having the driver variable as a static one so the screenshot listener worked perfectly during a failure. From today we wanted to implement parallel test execution and I faced problem due to the static driver variable. So when I made the driver as non-static screenshot listener got messed up.

So do you think implementing ThreadLocal will help me resolve both the aforementioned conditions?

Thanks,
Praveen


On Thu, Jul 11, 2013 at 10:00 PM, Krishnan Mahadevan <[hidden email]> wrote:
This should be a good start : 



On Friday, July 12, 2013, Praveen Bhasker wrote:
Hi Krishnan,

I consider all your solutions in the forum as extremely useful one. If you have any implemented code I kindly request you to pls share it. I did some googling and read something about ThreadLocal. but couldn't figure out much. Pls help me. Thanks a lot!

Thanks,
Praveen


On Thu, Jul 11, 2013 at 9:29 PM, Krishnan Mahadevan <[hidden email]> wrote:
Maybe you should take a look at ThreadLocal 

On Friday, July 12, 2013, talon wrote:
Hi,

I have a testcase that will invoke the driver as a non static variable. I also have added screenshot listener in my test case. When the test case fails The control is automatically sent to the screenshot listener.. however since my driver is a NON-STATIC variable it could not be accessed in the screenshot listener. So I get nullpointer exception.

Is there a way to globally access the non-static driver in the screenshot listener?

Pls help. Thanks!

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


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

--
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/NFZAmNnsSP4/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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Thanks & Re


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

--
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/NFZAmNnsSP4/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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.