in reply to Selenium RC - How to reuse bowser session?

I've seen mention of reusing the session in Java - but it seems to use a command not available in Perl - is that the case?

Link?

  • Comment on Re: Selenium RC - How to reuse bowser session?

Replies are listed 'Best First'.
Re^2: Selenium RC - How to reuse bowser session?
by zerocred (Beadle) on Mar 21, 2010 at 16:35 UTC
    http://groups.google.com/group/selenium-users/browse_frm/thread/40c943d3e8813af9/ed18dee8c7781dbe?lnk=gst&q=reuse+browser+session#ed18dee8c7781dbe
    public void startBrowser(String pstrBaseUrl, String pstrTimeou +tInMilliseconds) throws Exception { browser = new DefaultSelenium("localhost", 4444, "*chrome", ps +trBaseUrl); browser.start(); browser.setTimeout(pstrTimeoutInMilliseconds); }
    in the code in message 5. Unless I'm misunderstanding what is going on - (I dunno much about Java)

    This one is better:

    http://groups.google.com/group/selenium-users/browse_frm/thread/403b2b93e6e0e2b2/e16702ec4686cd1f?lnk=gst&q=reuse+browser+session+id#e16702ec4686cd1f
    RemoteControlConfiguration rcc = new RemoteControlConfiguration(); rcc.reuseBrowserSessions(); SeleniumServer ss = new SeleniumServer(rcc); ss.start();

    What is the RemoteControlConfiguration()? or is that a home made function somewhere

      Try manually setting/reusing
      my $sel = ...->new( session_id => 'magic string', # OR $sel->{session_id} = 'magic string';
      or, if getExistingBrowserSession exists
      $sel->{session_id} = $sel->get_string("getExistingBrowserSession", $sel->{browser_start_comma +nd}, $sel->{browser_url});
        Thanks that's great!
        This seems to sort of work, it does grab the same session if the session_id is in the constructor). I just found that I can get the existing session_id using

        $sel->retrieve_last_remote_control_logs();

        And can probably regex it out (I'm cut& pasting right now) - and store it somewhere if I leave the server running and relaunch my automation. Otherwise make a new session and then save teh session_id with that command or yours.

        Selenium complains if I give it a 'magic string' that is not a real existing session_id, but if I give it the id of a real, existing session that is up it seems happy to use it. That seems to mean it can't be started up with arbitary session_id the server has to generate one - but if that can be captured it can be reused

        However, selenium seems to require me to open a URL

        $sel->open_ok("$url");

        before it will allow clicking on anything. However this makes my site think I'm navigating away and makes a popup forcing me to choose to log out or abanodon the new attempts at hijacking the session! Needless to say, I didn't write the site I'm just trying to get it to do something quicker than I can type.

        Still this is progress!! - Thanks so much

        (off to bed now - I'll type up a full solution when I get it working)

      Also "session_id = Optional argument that can be used to reuse session_ids between test runs. This can make for faster testing." is mentioned as arguments for:

      $sel = WWW::Selenium->new( %args )

      In some (old?) documentation here:

      http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/perl/WWW-Selenium.html#element_locators

      but not in cpan