Forum: Ruby calling a javascript function with Mechanize

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
99f789e5ec91bcc6e8cc8404efe6d856?d=identicon&s=25 Rita Amritkar (ritz_amritkar)
on 2008-01-03 08:56
(Received via mailing list)
Hi all,

       I am using Mechanize. I can get the particular contents but I
am not getting the expected data. There is a function in javascript
as,
window.onload = function() {
        if (location && location.search == "") {
          location.replace('/po3/?_d');
        } else {
          location.replace('/po3/' + location.search + '&_d=1');
        };
      };

I think this function is not getting called so I am not able to get
the expected data. I want to call this function with Mechanize.

Please help me...

Thanks in advance.
0cbb8bf6889de00150ddf9ac3062199b?d=identicon&s=25 Kamal Fariz (Guest)
on 2008-01-03 09:25
(Received via mailing list)
> There is a function in javascript
>
> snip
>
> I think this function is not getting called so I am not able to get
> the expected data. I want to call this function with Mechanize.

Mechanize can't evaluate javascript. The creator of Mechanize, Aaron
Patterson, is working on a new project called RKelly which has the
goal of being able to evaluate Javascript in Ruby.

Until then, your only solution is to use Selenium or Watir to control
an actual browser.

Regards,
Kamal
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jano Svitok (Guest)
on 2008-01-03 12:25
(Received via mailing list)
On Jan 3, 2008 9:24 AM, Kamal Fariz <kamal@ror.com.my> wrote:
>
> Until then, your only solution is to use Selenium or Watir to control
> an actual browser.

IIRC scrubyt uses firewatir for similar cases, so you may have better
luck using that. (http://scrubyt.org/)
E41c5c2562a8eccb023acb6e14b22cc0?d=identicon&s=25 ilpuccio.febo@gmail.com (Guest)
on 2008-01-04 11:15
(Received via mailing list)
On Jan 3, 12:23 pm, Jano Svitok <jan.svi...@gmail.com> wrote:
> > Patterson, is working on a new project called RKelly which has the
> > goal of being able to evaluate Javascript in Ruby.
>
> > Until then, your only solution is to use Selenium or Watir to control
> > an actual browser.

Take a look here:
http://code.google.com/p/ruby-spidermonkey/
would be very interesting binding javascript engine directely in ruby.

> IIRC scrubyt uses firewatir for similar cases, so you may have better
> luck using that. (http://scrubyt.org/)
Can you point me on that kind of example, plz?
This topic is locked and can not be replied to.