pmneve
pmneve

Reputation: 626

How can one get the running version of selenium, selenium server, or selenium webdriver programmatically?

I'm running automated tests in several environments and need to know what is actually being used at run time.

I'm seeing different issues with identical Ruby scripts and would like to be able to capture as many environmental parameters as possible during the runs so they can be included in the run reports to help narrow down possible causes for the differences.

All environments are running Windows 7 64 SP1 and Ruby 2.0.0p451 (2014-02-24) [i386-mingw32]. Most serious issues are with IE (really??) and all environments are running the same IE version and build.

Any suggestions are most welcome.

pat

Upvotes: 2

Views: 2204

Answers (3)

pmneve
pmneve

Reputation: 626

A bit ugly but I finally got something that works for iedriverserver and chromedriver, the trick being to get the sysout and syserr as well as the pid so the process can be killed.

r, w = IO.pipe
pid1 = Process.spawn('iedriverserver', :out => w, :err => [:child, :out])
puts "#{__LINE__}: #{pid1}"
sleep(1)
k = Process.kill('KILL', pid1)
puts "#{__LINE__}: #{k}"
w.close
pid2, status = Process.wait2
puts "#{__LINE__}: #{pid2}, #{status}"
out = r.read
r.close
puts out

(Finally figured out the code markup... ;) )

Upvotes: 1

Dave Schweisguth
Dave Schweisguth

Reputation: 37647

You can get the version of a gem from the source_location of a method of one of its classes. For example:

Selenium::WebDriver.method(:for).source_location.first[/selenium-webdriver-\d+(?:\.\d+)*/]
=> "selenium-webdriver-2.53.0"

Upvotes: 1

Florent B.
Florent B.

Reputation: 42538

You could get the version of the driver by sending the status command to the driver:

require "selenium-webdriver"

driver = Selenium::WebDriver.for :ie
driver.navigate.to "http://stackoverflow.com/"

puts driver.send(:bridge).status

Upvotes: 0

Related Questions