robotframework / OldSeleniumLibrary

Deprecated Selenium library for Robot Framework
Apache License 2.0
13 stars 3 forks source link

Checking if selenium server is already running #224

Closed spooning closed 9 years ago

spooning commented 9 years ago

Originally submitted to Google Code by markhu on 9 Jan 2012

How would I detect if the server is already running?

I'm trying to structure my tests so that a selenium server and browser only needs to be created once.

Currently my setup and teardown for each test starts selenium, opens a browser, logs in, runs the test, logs out, closes browser, stops selenium for every single test.

Some ways I could do this would be:

  1. detect if the server is currently running and use existing instance
  2. only call start on a server if this is the 1st test to run and only call stop if it's the last test

For #2 I would need a way to know how many tests are currently in queue and which test I'm on.

Or is there a better way to approach this ?

Thanks.

spooning commented 9 years ago

Originally submitted to Google Code by markhu on 9 Jan 2012

I have also tried to run keywords that require a selenium server and browser instance to be open using the run keyword and ignore error style wrappers but they don't trap exceptions so entire suite fails at that point.

spooning commented 9 years ago

Originally submitted to Google Code by @pekkaklarck on 10 Jan 2012

My general recommendation is to start Selenium Server either before the execution or in highest level suite setup. If neither of these work for you, could you explain why? If there's a good enough reason, perhaps Start Selenium Server keyword could be changed so that it only starts the server once and running it again does nothing.

spooning commented 9 years ago

Originally submitted to Google Code by markhu on 10 Jan 2012

Well that sounds like a great idea.. I mean as far as selenium server goes I could also just create a global flag that marks it as started but there is possibility that it could crash so your suggestion is better..

As far as the top level suite how would I go about doing that? I believe I tried to create a top level resource file that contained suite setup and teardown but it does not run on it's own it has to be called by a test case I believe which means it would run setup/teardown for every single test which is currently where I am.

spooning commented 9 years ago

Originally submitted to Google Code by @pekkaklarck on 11 Jan 2012

Resource files cannot have setups/teardowns but both normal test case files and suite initialization files can have suite setup and suite teardown: http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html#suite-setup-and-teardown

spooning commented 9 years ago

Originally submitted to Google Code by markhu on 17 Jan 2012

Thanks that does the trick!

spooning commented 9 years ago

Originally submitted to Google Code by @pekkaklarck on 19 Jan 2012

Great. I think this issue can be closed.