# Execute javascript in Ruby

**URL:** <https://www.ruby-forum.com/t/execute-javascript-in-ruby/175159>\
**Category:** Ruby\
**Created:** [September 9, 2009, 7:56am UTC](https://www.ruby-forum.com/t/execute-javascript-in-ruby/175159 "2009-09-09T07:56:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chillexistence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@chillexistence](https://www.ruby-forum.com/u/chillexistence)\
**Post date:** [September 9, 2009, 7:56am UTC](https://www.ruby-forum.com/t/execute-javascript-in-ruby/175159/1 "2009-09-09T07:56:55Z")

</div>

Hello all!

I use ‘net/http’ lib for get and parse html pages. But I also need to  
execute some javascripts on pages from my ruby-scripts like on  
web-browsers. Is it possible? May be there are special libraries…  
Please advise.

---

<div class="post-metadata">

**Author:** ![chillexistence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@chillexistence](https://www.ruby-forum.com/u/chillexistence)\
**Post date:** [September 9, 2009, 10:29am UTC](https://www.ruby-forum.com/t/execute-javascript-in-ruby/175159/2 "2009-09-09T10:29:51Z")

</div>

> I use ‘net/http’ lib for get and parse html pages. But I also need to  
> execute some javascripts on pages from my ruby-scripts like on  
> web-browsers. Is it possible? May be there are special libraries…  
> Please advise.

Have a look at watir[1] or even celerity[2] (on jruby).

Those will let you pretend to be a browser, GET/POST pages and run  
javascript just as the real browser would.

kaspar

[1] [http://wtr.rubyforge.org/index.html](http://wtr.rubyforge.org/index.html)  
[2] [http://celerity.rubyforge.org/doc/](http://celerity.rubyforge.org/doc/)

---

<div class="post-metadata">

**Author:** ![chillexistence](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@chillexistence](https://www.ruby-forum.com/u/chillexistence)\
**Post date:** [September 9, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/execute-javascript-in-ruby/175159/3 "2009-09-09T18:18:51Z")

</div>

On Sep 8, 2009, at 10:56 PM, Andrew Andreev wrote:

> Hello all!
> 
> I use ‘net/http’ lib for get and parse html pages. But I also need to  
> execute some javascripts on pages from my ruby-scripts like on  
> web-browsers. Is it possible? May be there are special libraries…  
> Please advise.

Johnson embeds a JavaScript interpreter in Ruby. You might want to  
check that out:

> **[GitHub - jbarnette/johnson: Johnson wraps JavaScript in a loving Ruby embrace.](https://github.com/jbarnette/johnson)**
>
> Johnson wraps JavaScript in a loving Ruby embrace. - GitHub - jbarnette/johnson: Johnson wraps JavaScript in a loving Ruby embrace.

* * *

Aaron P.  
[http://tenderlovemaking.com](http://tenderlovemaking.com)
