Hello, Is there a way to include .js functions within my ruby script? Thanks
on 2013-01-09 00:16
Nicole, In short: no, there isn't. What are you trying to accomplish? We might be able to help you with this information. ----- Carlos Agarie Control engineering Polytechnic School, University of So Paulo, Brazil Computer engineering Embry-Riddle Aeronautical University, USA 2013/1/8 Nicole Villette <lists@ruby-forum.com>
on 2013-01-09 00:20
On 01/08/2013 04:54 PM, Nicole Villette wrote: > Hello, > > Is there a way to include .js functions within my ruby script? The Ruby interpreter can only directly run Ruby code. Javascript is not Ruby, obviously, so the only possible solution would be to find a way to load a Javascript interpreter and hook it up such that you can call into it for the functionality you need. You can probably do that most easily with JRuby since there are some Javascript interpreters available that run under Java (where JRuby itself runs), but I couldn't guess at how hard or easy it would really be to pull off. -Jeremy
on 2013-01-09 00:56
On Tue, Jan 8, 2013 at 3:19 PM, Jeremy Bopp <jeremy@bopp.net> wrote: >> Is there a way to include .js functions within my ruby script? > > The Ruby interpreter can only directly run Ruby code. Javascript is not > Ruby, obviously, so the only possible solution would be to find a way to > load a Javascript interpreter e.g. `gem install johnson` -- https://github.com/jbarnette/johnson Note: haven't used this in a long time, so can't vouch for suitability for whatever particular purpose the OP has in mind. :-)
on 2013-01-09 10:21
On Jan 9, 2013, at 12:54 AM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote: > Note: haven't used this in a long time, so can't vouch for suitability > for whatever particular purpose the OP has in mind. :-) There are multiple mature ways to embed a JS interpreter in Ruby: gem install therubyracer # V8 embedded in Ruby gem install therubyrhino # the same for JRuby, using Rhino See https://github.com/cowboyd/therubyracer for the README Be aware that this only gives you the javascript interpreter, not access to DOM manipulations etc.
on 2013-01-09 16:24
Thanks for all of your responses. I guess I would need to access the DOM somehow. I am doing some automation using selenium-webdriver and ruby. I am getting stuck on the part to upload an audio because it is a flash object that I can not interact with. So the developer created some js functions to get me through those clicks. The file with the functions that I am calling from my script is supposed to be on the audio upload page for ex. adCreationModule.js. So, I guess I need to get a reference to the DOM. I'm just not sure how to do that in Ruby.
on 2013-01-10 14:57
That is something completely different. What you'd like to do is evaluate javascript in webdriver. That is possible. See: http://code.google.com/p/selenium/wiki/RubyBindings
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.