Selenium more than one base level for each class

I am writing selenium scripts on a complex web application.

To use a user account, I need to first register using one URL and then approve the account in the admin console at a different URL.

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

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

Is there a trick I don't know about? I have been distracted for a long time by this problem and debug it, but selenium tests with isolation (test ↔ RCServer) do not facilitate the transition ...; -)

+4
source share
2 answers

Since you checked this selenium-rc, I assume you are using rc.

Just use two separate instances of selenium in the test client. There is no reason why you should have only one instance of selenium within the same class. In my opinion, this is even cleaner as you are talking with two different user interfaces.

On the server side, you still only need one. The server will happily launch two instances of the browser if asked to use two instances of the client.

Moritz

edit: just to add this, selenium can now be instantiated anytime with

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

Assuming the selenium server is on local port 4444.

+3
source

OK Selenium does not seem to be suitable for such a workflow.

I divided the test class into three test classes.

  • Basic registration using the first baseURL
  • Approval using seconf baseURL
  • Simple tasks using first baseURL again

This is not as clean as having the material contained in one test case, because it belongs together with the business point of view. But at least it works, and I don't need to crack selenium for that.

+1
source

Source: https://habr.com/ru/post/1309332/


All Articles