Best place to have driver instantiation

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

Best place to have driver instantiation

praveen133t
Hi... I would like to know the best place to have the driver instantiated. Right now I have the driver initiated in test base which is extended by test cases. Is it a good practice to have it initiated in every test cases? 

--
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: Best place to have driver instantiation

Yevhen Bilevych
IMHO wherever you put the code, the driver should get initialised before test and deinitialised after.
The outcomes are clean fixture (you don't bother if driver was left in wrong state) and parallel test execution.

The best places are 
- @BeforeMethod if your methods act as self-paced tests (and are annotated with @Test)
- @BeforeClass if your class acts as self-paced test with methods as sub-tests 

Don't forget deinitialise the driver.

Hope this helps

Yevhen

Sent from my BlackBerry® PlayBook™
www.blackberry.com


From: "talon" <[hidden email]>
To: "[hidden email]" <[hidden email]>
Sent: January 30, 2014 10:10 PM
Subject: [testng-users] Best place to have driver instantiation

Hi... I would like to know the best place to have the driver instantiated. Right now I have the driver initiated in test base which is extended by test cases. Is it a good practice to have it initiated in every test cases? 

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

--
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: Best place to have driver instantiation

praveen133t
So let's say all my action methods (Like inputting texts into a text box, clicking a link etc) comes from a different class file. So in that case this class file will not be able to access the driver if the driver is defined in the tests right. how do you go about that?

On Thursday, January 30, 2014 2:29:04 PM UTC-6, Yevhen Bilevych wrote:
IMHO wherever you put the code, the driver should get initialised before test and deinitialised after.
The outcomes are clean fixture (you don't bother if driver was left in wrong state) and parallel test execution.

The best places are 
- @BeforeMethod if your methods act as self-paced tests (and are annotated with @Test)
- @BeforeClass if your class acts as self-paced test with methods as sub-tests 

Don't forget deinitialise the driver.

Hope this helps

Yevhen

Sent from my BlackBerry® PlayBook™
<a href="http://www.blackberry.com" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.blackberry.com\46sa\75D\46sntz\0751\46usg\75AFQjCNHhVAoGP92kw_iP7t1PltOLXP-DDw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fwww.blackberry.com\46sa\75D\46sntz\0751\46usg\75AFQjCNHhVAoGP92kw_iP7t1PltOLXP-DDw';return true;">www.blackberry.com


From: "talon" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="oOWjJm_EZjYJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">neevar...@...>
To: "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="oOWjJm_EZjYJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@..." <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="oOWjJm_EZjYJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@...>
Sent: January 30, 2014 10:10 PM
Subject: [testng-users] Best place to have driver instantiation

Hi... I would like to know the best place to have the driver instantiated. Right now I have the driver initiated in test base which is extended by test cases. Is it a good practice to have it initiated in every test cases? 

--
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" gdf-obfuscated-mailto="oOWjJm_EZjYJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="oOWjJm_EZjYJ" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">testng...@....
Visit this group at <a href="http://groups.google.com/group/testng-users" target="_blank" onmousedown="this.href='http://groups.google.com/group/testng-users';return true;" onclick="this.href='http://groups.google.com/group/testng-users';return true;">http://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/groups/opt_out" target="_blank" onmousedown="this.href='https://groups.google.com/groups/opt_out';return true;" onclick="this.href='https://groups.google.com/groups/opt_out';return true;">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: Best place to have driver instantiation

Shawn McCarthy-2
In reply to this post by praveen133t
I have mine in a BeforeMethod that all my frontend tests inherit.

On Thursday, January 30, 2014 1:10:11 PM UTC-7, talon wrote:
Hi... I would like to know the best place to have the driver instantiated. Right now I have the driver initiated in test base which is extended by test cases. Is it a good practice to have it initiated in every test cases? 

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