juil. 03

Recently, I was playing with WatiN to do some integration and web testing, and I have "discovered" the concept of session merging in the browsers.

What is this ? By default, the browsers (Internet Explorer, Firefox, ...) are sharing the session information of a website (for instance the authentication information) between its tabs and different instances. What does implies in practice ? Just launch one instance of your favorite browser and log into an application (mail, ...). Then launch another instance (for instance another process) of the same browser and go to the same website. You should be logged in, even if you had not checked the magic checkbox "Remember me". Why are they doing this ? Just because many websites expect this behavior. Just imagine how surfing would behave without session merging in an application when it open popups ?

Just note that all website do NOT manage their authentication in the same way, and so, some of them may not be affected by session merging.

So, that's a feature ok. But when you do some web testing and that you would like to launch several browser logged in with different users to check simultaneous actions or things like that, this feature can be very very annoying.

But Internet Explorer 8 has added a new feature, that allow you to surf in a new session, meaning you just deactivate explicitely the session merging. How to do that ? Simple:

  • either from an existing Internet Explorer windows, juts use the menu File / New Session
  • from command line, use IExplore.exe -nomerge

What about in COM ?

Let's go back to my testing session. I was manipulating the DLL "Interop.SHDocVw.dll" to drive my browser and to create a new instance of Internet Explorer, I was just using the syntax new InternetExplorerClass. So how can I use this feature using the COM component ? Well, so far, I haven't found any way to do that directly so I'm waiting for your comments ! :-)

Anyway, I am using a workaround, that has been highly inspired of the source code of WatiN, just updating it to take into account the notion of session merging, and giving enough time to Internet Explorer to start.

To make this compile, you will need two references:

  • Interop.SHDocVw.dll : The COM wrapper exposing the Internet Explorer's classes
  • WatiN.Core.dll : The DLL of WatiN to be able to use the very nice TryFuncUntilTimeOut class and to collect the running instances of IE using the ShellWindows2 class
using System;
using System.Diagnostics;
using SHDocVw;
using WatiN.Core.Native.InternetExplorer;
using WatiN.Core.UtilityClasses;
namespace ClassLibrary1
   public class IEFactory
      /// <summary>
      /// Start Internet Explorer without session merging
      /// </summary>
      /// <returns>The IE process</returns>
      private Process StartIEProcess()
         string argument = "-nomerge about:blank";
         var process = Process.Start("IExplore.exe", argument);
         if ( process == null )
            throw new InvalidOperationException("The IExplore.exe process can't be started");
         return process;
      /// <summary>
      /// Start a new instance of Internet Explorer and attach it to a IWebBrowser2 object
      /// </summary>
      /// <returns>The COM object corresponding to the running instance</returns>
      public IWebBrowser2 DemarreInstanceCOM()
         //1. Let's count the current number of IE instances
         int count = new ShellWindows2().Count;
         //2. Start the process
         Process process = StartIEProcess();
         //3. Let's find the handle of the new running IE
         //   We will try for a maximum of 5 seconds, with trial every 100ms 
         //   if we had not been successful
         var getWindowHandle = new TryFuncUntilTimeOut(5) { SleepTime = 100 };
         int windowHandle = getWindowHandle.Try<int>(() => process.MainWindowHandle.ToInt32());
         //4. If we got the handle, let's get the browser
         var allBrowsers = new ShellWindows2();
         if ( windowHandle != 0 )
            foreach ( var browser in allBrowsers )
               if ( ( (IWebBrowser2)browser ).HWND == windowHandle )
                  return browser as IWebBrowser2;
         //5. Otherwise, let's take the first instance on a blank page
            //for that we'll wait until a new instance of IE is running
            var action = new TryFuncUntilTimeOut(5) { SleepTime = 100 };
            action.Try<bool>(() => new ShellWindows2().Count > count);
            foreach ( var browser in new ShellWindows2() )
               if ( ( (IWebBrowser2)browser ).LocationURL == "about:blank" )
                  return browser as IWebBrowser2;
         //6. We had not been able to start the instance
         throw new InvalidOperationException("Internet Explorer could not be started");

Other information ?

Here is the link to the blog I have found explaining about session merging : http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-and-ie8.aspx



Posted on mardi, 11 août 2009 18:35

Nice post. I see it fixed in nightlly build of WatN.  
Set Settings.MakeNewIe8InstanceNoMerge to true.

Pierre-Emmanuel Dautreppe

Posted on jeudi, 20 août 2009 14:35

Thanks for the info!
I have some difficulties with WaitN when too many tests are being run, but I will try to update soon !



Posted on vendredi, 26 juillet 2013 15:30

I am really impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a great blog like this one these days.

Feel free to surf to my blog post: site referencement google [ Tamika - tothepope.org/.../article_page.php%2C+I%27ve+recently+been+looking+for+information+about+this+subject+for+a+long+time+and+yours+is+the+greatest+I%27ve+found+out+till+now.%3Cbr%3EBut%2C+what+in+regards+to+the+bottom+line%3F+Are+you+certain+concerning+the+source%3F%3Cbr%3E%3Cbr%3E%3Cbr%3EHere+is+my+page%3B+%3Ca+href%3D%22http%3A%2F%2Fenewsletter.catawbacountync.gov%2Fwiki%2Findex.php%3Ftitle%3DUser%3ABobNoeldvypnzs%22%3Ereferencer+un+site+internet%3C%2Fa%3E&content=Thanks+%2C+I%27ve+recently+been+looking+for+information+about+this+subject+for+a+long+time+and+yours+is+the+greatest+I%27ve+%3Cbr%3Efound+out+till+now.+But%2C+what+in+regards+to+the+bottom+line%3F%3Cbr%3EAre+you+certain+concerning+the+source%3F%3Cbr%3E%3Cbr%3Emy+site+%3A%3A+%3Ca+href%3D%22http%3A%2F%2Fenewsletter.catawbacountync.gov%2Fwiki%2Findex.php%3Ftitle%3DUser%3ABobNoeldvypnzs%22%3Ereferencer+un+site+internet%3C%2Fa%3E&author=Numbers&email=numbers_colwell%40inoutbox.com&webpage=http%3A%2F%2Fenewsletter.catawbacountync.gov%2Fwiki%2Findex.php%3Ftitle%3DUser%3ABobNoeldvypnzs&er=true ]

seo link service

Posted on mardi, 30 juillet 2013 02:02

Nice blog here! Also your web site loads up fast! What host are you using? Can I get your affiliate link to your host? I wish my site loaded up as fast as yours lol

My page -  seo link service - fiverr.com/.../create-you-1000-unique-social-bookmarks-and-ping-them



Posted on samedi, 3 août 2013 16:09

Hey there are using Wordpress for your blog platform? I'm new to the blog world but I'm trying to get started and create my own. Do you require any html coding knowledge to make your own blog? Any help would be greatly appreciated!

my weblog; google referencer son site ( Gladys - tothepope.org/.../article_page.php%2C+simply+pay+a+quick+visit+this+web+%3Cbr%3Esite+daily+for+the+reason+that+it+provides+quality+contents%2C+thanks%3Cbr%3E%3Cbr%3EAlso+visit+my+web+site+...+%3Ca+href%3D%22http%3A%2F%2Fyourlastwrite.com%2Fstory.php%3Ftitle%3Dgoogle-referencer-son-site%22%3Ereferencer+un+site%3C%2Fa%3E&content=If+you+are+going+for+finest+contents+like+myself%2C+simply+pay+a+quick+visit+this+web+site+daily+for+the+reason+that+%3Cbr%3Eit+provides+quality+contents%2C+thanks%3Cbr%3E%3Cbr%3Emy+homepage+-+%3Ca+href%3D%22http%3A%2F%2Fyourlastwrite.com%2Fstory.php%3Ftitle%3Dgoogle-referencer-son-site%22%3Ereferencer+un+site%3C%2Fa%3E&author=Alejandrina&email=alejandrina_cruz%40web.de&webpage=http%3A%2F%2Fyourlastwrite.com%2Fstory.php%3Ftitle%3Dgoogle-referencer-son-site&er=true )


Posted on vendredi, 9 août 2013 01:17

If you are going for most excellent contents like I do, just pay a visit this site all the time since it presents feature contents, thanks

Feel free to visit my weblog ::  seopowa - www.google.com/custom%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A1&hl=pl

wilmington nc

Posted on samedi, 2 novembre 2013 16:27

I used to be suggested this web site by means of my cousin. I'm now not certain whether or not this put up is written through him as no one else understand such distinct approximately my problem. You're amazing! Thanks!

My web blog:  wilmington nc - http://wordwrightweb.com/

トリーバーチ 長財布 アウトレット

Posted on lundi, 9 décembre 2013 12:20

トリーバーチ 長財布 アウトレット - http://www.12angrymascots.com/tb/トリーバーチ-アウトレット.html  Wow that was odd. I just wrote an incredibly long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Anyhow, just wanted to say excellent blog!  トリーバーチ 長財布 アウトレット - http://www.12angrymascots.com/tb/トリーバーチ-アウトレット.html

ugg ブーツ ファスナー

Posted on mercredi, 11 décembre 2013 20:44

ugg ブーツ ファスナー - www.swissschoolbangkok.org/cli/agubutsu.php?56  I know this if off topic but I'm looking into starting my own blog and was wondering what all is required to get set up? I'm assuming having a blog like yours would cost a pretty penny? I'm not very web smart so I'm not 100% sure. Any suggestions or advice would be greatly appreciated. Thank you  ugg ブーツ ファスナー - www.swissschoolbangkok.org/cli/agubutsu.php?56

エルメス バッグ 店舗

Posted on jeudi, 19 décembre 2013 13:25

エルメス バッグ 店舗 - www.prospectiva.com/newsletter/erumesu.php?146  An impressive share! I have just forwarded this onto a colleague who has been conducting a little research on this. And he actually ordered me dinner because I found it for him... lol. So let me reword this.... Thank YOU for the meal!! But yeah, thanx for spending some time to talk about this subject here on your web page.  エルメス バッグ 店舗 - www.prospectiva.com/newsletter/erumesu.php?146


Posted on vendredi, 20 décembre 2013 07:17

Wow! This blog looks exactly like my old one! It's on a completely different subject but it has pretty much the same page layout and design. Excellent choice of colors!

Feel free to visit my webpage -  website - http://donharubang.com/xe/?document_srl=23240

財布 ルイヴィトン コピー

Posted on mercredi, 25 décembre 2013 11:17

I will right away grasp your rss feed as I can't to find your email subscription hyperlink or newsletter service. Do you've any? Kindly permit me know in order that I may just subscribe. Thanks.

my blog  財布 ルイヴィトン コピー - http://activatingamerica.com/du0uvj.html

セリーヌ バッグ ピンク

Posted on vendredi, 27 décembre 2013 15:42

Hi, just wanted to tell you, I loved this blog post. It was inspiring. Keep on posting!

Here is my webpage;  セリーヌ バッグ ピンク - http://www.interiordesigner-ideas.com/ihtjkq.html

シャネル 財布 ピンク エナメル

Posted on mardi, 31 décembre 2013 03:56

Hi there! Someone in my Myspace group shared this site with us so I came to take a look. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Terrific blog and outstanding design and style.

Also visit my web-site;  シャネル 財布 ピンク エナメル - http://internetmoneymap.com/mgpftv.html

Ajouter un commentaire

  • Commentaire
  • Aperçu immédiat