How to keep the browser open even after the test is complete

22,257 views
Skip to first unread message

Vaibhav Misra

unread,
Jun 21, 2013, 1:08:17 PM6/21/13
to seleniu...@googlegroups.com
Hi All,

Is there a way to keep the browser window open even after the test execution is complete? I am trying to search different strings in a log file and if relevant results are found then i would like to keep the browser open so that results can be viewed at a later time.

But the browser window closes after 5 minutes (approx.) of test execution. Is there any option by which i can extend this time period?

Selenium 2.33, Win 7, FF and Chrome. I am using remote web driver class.

Satya Goyal

unread,
Jun 22, 2013, 2:28:29 AM6/22/13
to seleniu...@googlegroups.com
use thread.sleep(50000); before call driver.quit();



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/304ae244-0bcb-49ed-b972-53a66c948116%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thanks and Regards,
/Satya

Vaibhav Misra

unread,
Jun 22, 2013, 2:57:41 AM6/22/13
to seleniu...@googlegroups.com
I had thought about putting a sleep but is there a more clean way to achieve it. inserting a sleep can always be done 

Krishnan Mahadevan

unread,
Jun 22, 2013, 4:09:37 AM6/22/13
to seleniu...@googlegroups.com
Why wouldn't the following work instead of leaving a browser open and creating an unstable automation environment ?

If the search in the log is successful then 
1. Take a screenshot
2. Extract the page source and save it to the file system. 

Wouldnt that be a lot more cleaner solution instead of leaving the browser open and inducing manual intervention required for automation ?

Also remember that the browser is controlled internally by a timeout at the WebDriver level which means after sometime WebDriver is probably going to clean up your browser instance anyway. I don't remember the exact setting but I think its there. 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

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/

Vaibhav Misra

unread,
Jun 22, 2013, 4:46:02 AM6/22/13
to seleniu...@googlegroups.com
Taking screen shot wont work as for some strings the search results returned run into several pages.

Taking source page of all the results...how can i achieve that and it sounds complex.....thats why i was looking for a way to keep the tab open.

The results (bunch of exceptions) of the search will be evaluated manually eventually so that is no issue.


On Saturday, June 22, 2013 1:39:37 PM UTC+5:30, Krishnan wrote:
Why wouldn't the following work instead of leaving a browser open and creating an unstable automation environment ?

If the search in the log is successful then 
1. Take a screenshot
2. Extract the page source and save it to the file system. 

Wouldnt that be a lot more cleaner solution instead of leaving the browser open and inducing manual intervention required for automation ?

Also remember that the browser is controlled internally by a timeout at the WebDriver level which means after sometime WebDriver is probably going to clean up your browser instance anyway. I don't remember the exact setting but I think its there. 



On Saturday, June 22, 2013, Vaibhav Misra wrote:
I had thought about putting a sleep but is there a more clean way to achieve it. inserting a sleep can always be done 

On Friday, June 21, 2013 10:38:17 PM UTC+5:30, Vaibhav Misra wrote:
Hi All,

Is there a way to keep the browser window open even after the test execution is complete? I am trying to search different strings in a log file and if relevant results are found then i would like to keep the browser open so that results can be viewed at a later time.

But the browser window closes after 5 minutes (approx.) of test execution. Is there any option by which i can extend this time period?

Selenium 2.33, Win 7, FF and Chrome. I am using remote web driver class.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

Vaibhav Misra

unread,
Jun 24, 2013, 10:12:24 AM6/24/13
to seleniu...@googlegroups.com
I even tried using thread.sleep for a duration of 3600 seconds but still FF browser closes after 5 mins....i have removed the code where i use driver.quit and still browser closes.

Any suggestions.....please help!!!! 

Krishnan Mahadevan

unread,
Jun 24, 2013, 10:28:54 AM6/24/13
to Selenium Users
You need to revisit your approach. Leaving the browser open is NOT going to help you here.

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/


To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/155c1270-abb3-43a4-b4ae-94b0a5aea0db%40googlegroups.com.

Siva

unread,
Jun 24, 2013, 10:34:31 AM6/24/13
to seleniu...@googlegroups.com
Don`t give driver.quit() option as the last command.

Browser will wait till you close manually

Arran

unread,
Jun 24, 2013, 11:49:40 AM6/24/13
to seleniu...@googlegroups.com
Agreed. If you need to verify your test results manually it's not exactly an automated test is it?

Makes no sense. Either automate it or not. Don't go for in the middle. It increases the pain you have to deal with.

Vaibhav Misra

unread,
Jun 24, 2013, 12:13:15 PM6/24/13
to seleniu...@googlegroups.com
Ok...i get what you guys are saying but I will try to rephrase the scenario... so that u understand my dilemma.

I have been provided with a list of exceptions and i need to search the logs for occurrence of these exceptions. The list of exceptions may change from time to time.

My code searches for each exception in a different tab and only keeps those tabs open where results are found. I have to give this code to developer who will be using it. But chances are this code will be run in background and the dev will look at the results some time later.

Therefore the need to keep the browser open even after the tests have complete at least for a duration of 30 mins or so.

Does this make sense?? I hope you guys will see some logic in my requirement (I can not use screen shot as results of some searches run into several pages)

Gustavo Godoy

unread,
Jun 24, 2013, 2:06:31 PM6/24/13
to seleniu...@googlegroups.com
Let me understand..
Your browser chow you some log (in the html view of the browser), and when you find something you think is relevant, you have to take the browser open to someone see this relevant information. If not, you can close.

This is alright? If your search in the page is successful, you have to show to other people, and he have to search the page to? Or your search in the log refers to, after you interact to web page, you search a log file in filesystem and, when you find, you have to leave web page open to verify manually?

Gustavo Godoy

unread,
Jun 24, 2013, 2:11:52 PM6/24/13
to seleniu...@googlegroups.com
If you just need to keep browser open, don't quit your remote call (driver.quit()) and add a specific timeout when you starts your server (this example is for remote)

http://code.google.com/p/selenium/wiki/RemoteWebDriverServer




On Friday, June 21, 2013 2:08:17 PM UTC-3, Vaibhav Misra wrote:

Vaibhav Misra

unread,
Jun 25, 2013, 3:41:37 AM6/25/13
to seleniu...@googlegroups.com
Hi Gustavo,

Thanks a lot for your pointing me in the right direction. Luckily i am using RemoteWebDriver Only and after playing a little with the timeout switch as mentioned in the article you mentioned....i was able to set it to 0. Now the browser window is not closing and i am able to achieve what i wanted.

Thanks again!!!

-Vaibhav

Gustavo Godoy

unread,
Jun 25, 2013, 8:39:53 AM6/25/13
to seleniu...@googlegroups.com
I'm glad that helped you! :)


On Friday, June 21, 2013 2:08:17 PM UTC-3, Vaibhav Misra wrote:

shivanand havannavar

unread,
Jun 25, 2013, 11:42:27 AM6/25/13
to seleniu...@googlegroups.com
Hello Vaibhav,
                          Try using implicit wait.... if u can do it in remote driver...

-Shiva

Sandeep Mishra

unread,
Mar 22, 2018, 1:15:27 AM3/22/18
to Selenium Users
Hi,

Can you please send me exact solution. I am getting same issue.

Mian Shazy

unread,
Jan 22, 2019, 10:59:27 PM1/22/19
to Selenium Users
The link Gustavo posted does not work anymore. Can you please mention the solution here

Rhicha Satam

unread,
Jan 28, 2019, 4:01:47 AM1/28/19
to seleniu...@googlegroups.com
Hi,

Remove driver.close(); or driver.quit(); command from your selenium
script, to keep the browser open even after the test is complete
driver.close(); -command is used to close current browser instance.
driver.quit();-command is used to close all the open browser instances.

Regards,
Rhicha

On Wed, Jan 23, 2019 at 9:29 AM Mian Shazy <shahza...@gmail.com> wrote:
>
> The link Gustavo posted does not work anymore. Can you please mention the solution here
>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
> To post to this group, send email to seleniu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/d1334ca2-3ee0-4b0d-87f3-f33a642c7f4f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages