ph7 / selenium-client

Official Ruby client API for Selenium Remote Control (bare bone client driver)
http://rubyforge.org/projects/selenium-client/
Apache License 2.0
153 stars 47 forks source link

ability to define DISPLAY when running selenium-server.jar #8

Closed balinterdi closed 15 years ago

balinterdi commented 15 years ago

When running selenium without a "visible" windowing system loaded defining the DISPLAY variable can be very useful.

In my case I wanted my CI server to automatically run my selenium tests but they failed since they want to start the browser without defining the DISPLAY where it will run. (see here:: http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+Integration)

So after a couple of hours of looking into how things work, I realized what I had to do was to insert the DISPLAY definition in front of the command that runs the selenium-server jar file. Something like this:

(remote_control.rb)

def start(options = {})
  command = "DISPLAY=:1 "
  command << "java -jar \"#{jar_file}\""
  command << " -port #{@port}"
  command << " -timeout #{@timeout_in_seconds}"
  command << " #{additional_args.join(' ')}" unless additional_args.empty?
  command << " > #{log_to}" if log_to

  @shell.run command, {:background => options[:background]}
end

That feels like a hack, though so I wonder if there is a nicer option or whether you think this is the right approach.

ph7 commented 15 years ago

Why not set the DISPLAY env variable at the shell level / for the rake task starting Selenium RC?

rake selenium:rc:start DISPLAY=:1

balinterdi commented 15 years ago

You are totally right, setting that env. var does not belong to the code.

In my case, I guess I'll have to set it when running the CI server since it is the CI server that runs the rake task.

Thank you.