Hello,
Is there a way to include .js functions within my ruby script?
Thanks
···
--
Posted via http://www.ruby-forum.com/.
Hello,
Is there a way to include .js functions within my ruby script?
Thanks
--
Posted via http://www.ruby-forum.com/.
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 São Paulo, Brazil
Computer engineering
Embry-Riddle Aeronautical University, USA
2013/1/8 Nicole Villette <lists@ruby-forum.com>
Hello,
Is there a way to include .js functions within my ruby script?
Thanks
--
Posted via http://www.ruby-forum.com/\.
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 01/08/2013 04:54 PM, Nicole Villette wrote:
Hello,
Is there a way to include .js functions within my ruby script?
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.
--
Posted via http://www.ruby-forum.com/.
e.g. `gem install johnson` -- GitHub - jbarnette/johnson: Johnson wraps JavaScript in a loving Ruby embrace.
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 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
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
That is something completely different. What you'd like to do is evaluate javascript in webdriver. That is possible.
See:
On Jan 9, 2013, at 4:24 PM, Nicole Villette <lists@ruby-forum.com> wrote:
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.--
Posted via http://www.ruby-forum.com/\.
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 Jan 9, 2013, at 12:54 AM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:
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 interpretere.g. `gem install johnson` -- GitHub - jbarnette/johnson: Johnson wraps JavaScript in a loving Ruby embrace.
Note: haven't used this in a long time, so can't vouch for suitability
for whatever particular purpose the OP has in mind.