Cleaning up lingering browser sessions webdriver selenium c#

2,005 views
Skip to first unread message

Shaba K

unread,
Aug 9, 2012, 10:53:07 AM8/9/12
to seleniu...@googlegroups.com
Hi All,

Though i call up driver.Quit(); at the end of each test.

i still see browser sessions visible when i execute as a test suite.

Can anyone let me know how in there framework implentation they has dealt with it.

This most often happens when the driver fails to indetify an object & the test fails but the browser session remain.

here's how i have written.

Am on C# WebDriver -Selenium  across browsers.


                              [Test]
                                public void TestSomething() 
                                {
                                    Drivercontext context = null;
                                            try
                                            {
                                                context = Drivercontext.Create("HomePageTests", BaseModule.GetobjLookup());
                                                HomeModule homeModule = new HomeModule();
                                                homeModule.GetHomepage().FollowUS(context, BaseModule.ObjectLookup["faceBookUI"]);
                                               
                                            }finally{
                                               if (context != null){context.Cleanup();}
                        
                                            }
                             }


my ccleanup () looks like below.

 public void Cleanup()
        {
            Console.WriteLine("CleanUp and quit Driver.....");
            if (driver != null)
            {
                driver.Manage().Cookies.DeleteAllCookies();
             //   driver.Quit(); //stopping the driver
                driver.Dispose();

            }
        }




Jim Evans

unread,
Aug 9, 2012, 1:36:27 PM8/9/12
to seleniu...@googlegroups.com
Your driver.Quit() call is commented out. Calling the .Quit() method is the only way to guarantee that sessions are properly terminated.

Shaba K

unread,
Aug 9, 2012, 5:31:39 PM8/9/12
to seleniu...@googlegroups.com
Hi Jim,

I use driver.Quit();

Here's the scenario i'l try best to explain what's happening.

1.Launch browser - > opens the requested url.
2.Perform an action -> close a appearing pop up
3.As it is failing to locate the pop up within the 60 sec time frame 

Test fails.-> All my other tests cleanup even if they fail.

Am assuming that as there is no action performed or what ever may be the reason.

It never clears/quits the browser.

Any thoughts,ideas are highly appreciated.

cheers,
s

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/zFZAv-YLQNIJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mike Riley

unread,
Aug 12, 2012, 1:40:54 PM8/12/12
to seleniu...@googlegroups.com
Not in the code you posted you don't.  In that code you are calling driver.Dispose().

Mike

Shaba K

unread,
Aug 12, 2012, 5:27:55 PM8/12/12
to seleniu...@googlegroups.com
hey Mike,

I tried out with dispose(); to see if that clears up.

cheers,
s

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/eDiZlFQgPX4J.
Reply all
Reply to author
Forward
0 new messages