Search code examples
phpseleniumselenium-rc

Selenium more than one baseUrl per test class


I am writing selenium scripts on a complex web based application.

To use a useraccount I need to register first using one URL and then approve the account in the admin console on another URL.

The problem is that there is another baseURL for registration and admin console and I need that in one unittest.

But when I use setBaseUrl in my tests it's ignored and the old baseURL is used. I even called start() after that, but no change...

Is there a trick that I am not aware of? I'm playing around and debug for quite some time on this problem, but the decoupled (test <-> RCServer) selenium tests are not making it easier to step through... ;-)


Solution

  • Since you tagged this selenium-rc, I assume you use rc.

    Just use two separate selenium instances in the test client. There is no reason why you should have only one selenium instance within one class. That is even cleaner in my opinion since you are talking to two different user interfaces.

    On the server side, you still need only one. The server will happily launch two browser instances if requested to do so using two client instances.

    Moritz

    edit: Just to add this, a now selenium instance can be created anytime with

    Selenium s = new DefaultSelenium("localhost", 4444, "*chrome", 
                "http://your-target-url");
    

    Assuming the selenium server is on localhost port 4444.