!!

Welcome to Selenium Webdriver Forum

As a web user you can read and search through forum content. Once you have registered and signed you can post topics, post replies, set up watch lists, modify forum settings, and use private messaging.

Author Topic: Unable to start selenium proxy from cygwin using Selenium gem  (Read 810 times)

morganizeit

  • Web User
Unable to start selenium proxy from cygwin using Selenium gem
« on: February 21, 2012, 06:37:13 PM »
Folks,
 [Posting here 'cause Shane Duan thought it was a good idea]
 
It's great to be running the Selenium proxy straight from Ruby.  Works
 great on my Mac.  Unfortunately, my fellow developers on Windows are
 not so lucky.  I have them developing ruby under Cygwin, and
 apparently Cygwin can't access a jar file using Unix style paths.
 Here's the error output:
 
java  -jar
 /usr/lib/ruby/gems/1.8/gems/Selenium-1.1.14/lib/selenium/openqa/
 selenium-server.jar.txt -multiWindow
 Unable to access jarfile /usr/lib/ruby/gems/1.8/gems/Selenium-1.1.14/
 lib/selenium/openqa/selenium-server.jar.txt
 
Running the command above that the gem is executing directly from
 command line results in the same error.  The only way I can start the
 proxy successfully is by going to that directory and running is from
 there, e.g:
 
cd /usr/lib/ruby/gems/1.8/gems/Selenium-1.1.14/lib/selenium/openqa
 java -jar selenium-server.jar.txt -multiWindow
 
I've tried "chmod 777" on the jar file, no luck.  I may have a lead
 based on this post:
 http://www.bernzilla.com/2008/05/12/unable-to-access-jar-file-from-a-...
 
The JDK is installed as a windows binary so it doesn't understand how
 to process a *nix style path.  I'm continuing the search for a
 workaround, any suggestions would be much appreciated.
 
I originally decided to use the Cygwin environment for ruby
 development on Windows to try and avoid compatibility problems.
 Ironic, yes?
 

- Show quoted text -

Shane Duan

  • Web User
Re: Unable to start selenium proxy from cygwin using Selenium gem
« Reply #1 on: February 21, 2012, 06:37:27 PM »
Hi,
 Is it that in cygwin all classpath should use windows format?  Can you
 try it out and let me know?
 
Can you also do me a favor by starting irb in cygwin and type 'puts
 RUBY_PLATFORM' and let me know what it says?
 
I think I have an idea of how to make this work, but would like to
 confirm some facts.
 
Thanks
 Shane
 


- Show quoted text -

--
 Shane
 http://www.shaneduan.com

morganizeit

  • Web User
Re: Unable to start selenium proxy from cygwin using Selenium gem
« Reply #2 on: February 21, 2012, 06:37:35 PM »
W00t!  I got it fixed.  I use a script called "start.rb" to start the
 proxy, so in that script I've overridden SeleniumServer::run to
 translate the path to the jar with cygpath if the script is run in the
 cygwin environment.  Should be a simple patch if you guys want to do
 it.
 CODE:
 
#!/usr/bin/env ruby
 
require 'rubygems'
 gem 'Selenium'
 require 'selenium'
 
args = ['-multiWindow']
 args += ARGV
 
module Selenium
 
  # Selenium server driver that provides API to start/stop server and
 check if
   # server is running.
   # NOTE: The start does not return until the server shuts down.
   class SeleniumServer
     # NOTE: overrode here to make the script run under Cygwin
     def SeleniumServer::run(argv, vmparameter='')
       jar_file = SeleniumServer.jar_file
       if (RUBY_PLATFORM == "i386-cygwin")
         jar_file = backtick("cygpath", "-w",
 "#{jar_file}").tr("\n","")
       end
       if (argv[0] == '-stop')
         server = SeleniumServer.new(argv[1])
         puts "stopping server on port #{server.port_number}"
         server.stop
       elsif argv[0] == '-check'
         server = SeleniumServer.new(argv[1])
         if (server.running?)
           puts "server running on #{server.port_number}"
         else
           puts "server not running on #{server.port_number}"
         end
       else
         command = "java #{vmparameter} -jar \"#{jar_file}\"
 #{argv.join(' ')}"
         puts command
         system(command)
       end
     end
   end
 
end
 
Selenium::SeleniumServer.run(args)
 
On Jul 29, 6:00 pm, "Shane Duan" <shane.d...@gmail.com> wrote:
 

- Show quoted text -

Selenium Webdriver

Re: Unable to start selenium proxy from cygwin using Selenium gem
« Reply #2 on: February 21, 2012, 06:37:35 PM »

Shane Duan

  • Web User
Re: Unable to start selenium proxy from cygwin using Selenium gem
« Reply #3 on: February 21, 2012, 06:37:44 PM »
yes that is where I was going.  Thanks for the code!
 I'll put this to the project and publish a point point release.
 
Cheers
 Shane
 


- Show quoted text -

--
 Shane
 http://www.shaneduan.com

morganizeit

  • Web User
Re: Unable to start selenium proxy from cygwin using Selenium gem
« Reply #4 on: February 21, 2012, 06:37:53 PM »
Whups, the line below the starts with "backtick" should be:
 jar_file = `cygpath -w "#{jar_file}"`.tr("\n","")
 
Great to see the devs on this project are so responsive!
 
Cheers,
 Morgan.
 
On Jul 29, 6:47 pm, "Shane Duan" <shane.d...@gmail.com> wrote:
 

- Show quoted text -

Shane Duan

  • Web User
Re: Unable to start selenium proxy from cygwin using Selenium gem
« Reply #5 on: February 21, 2012, 06:38:01 PM »
Hi,
 Apparently when I said publish, I didn't mean within a month.  I hope
 this is still fine with you since you have your local patch working.
 
I finally got sometime on the long weekend and am looking into this.
 I feel that if the path delimiter is the only problem, I should just
 fix that.  Can you let me know why you need to call into cygpath in
 your code?
 
I have checked in the code:
 
http://github.com/wolfdancer/selenium/commit/1a8c4b98d9422b2b95e707ef...
 http://github.com/wolfdancer/selenium/commit/bc065804d5e79264f065d3da...
 
Thanks
 Shane
 


- Show quoted text -

--
 Shane
 http://www.shaneduan.com

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
482 Views
Last post February 21, 2012, 08:07:02 PM
by Philippe Hanrigou
9 Replies
1502 Views
Last post April 01, 2012, 02:22:13 PM
by François Reynaud
7 Replies
810 Views
Last post April 03, 2012, 03:26:25 PM
by Mike Riley
1 Replies
463 Views
Last post April 15, 2012, 05:02:10 PM
by Fratiman Vladut
11 Replies
982 Views
Last post April 18, 2013, 05:22:04 AM
by vinayakjadhav1857
6 Replies
506 Views
Last post July 24, 2012, 10:04:11 PM
by Carrying_Smiles
6 Replies
1076 Views
Last post July 25, 2012, 03:32:33 PM
by kmanchu

Review www.seleniumwebdriver.com on alexa.com