Hi,
I am new on this forum and first I would like to greet all the perlmonks.
My question is about the use of MozRepl module.
I have installed the add-on MozRepl for firefox and started it. The MozRepl perl module is of course installed.
I would like to automate some tasks with firefox, and think it is a good idea to use MozRepl.
For simple examples, it seems to work good.
For instence, in the following code, after the connection to mozrepl, I load a new html page and execute some instructions, to get all the links in the page. Then, still using commands that I could use in a console mode, I create the function all_a without parameter to display all the links founded before using the javascript function 'alert', and finaly click on the fourth link of the list.

#!/usr/bin/perl -w use strict; use warnings; use MozRepl; my $repl = MozRepl->new; $repl->setup; $repl->execute('content.document.location.href="http://www.google.fr/f +irefox"'); $repl->execute('repl.whereAmI()'); $repl->execute('repl.enter(content)'); $repl->execute('a = document.getElementsByTagName("a")'); $repl->execute('function all_a() {var all=""; for(var i=0;i<a.length;i +++) {all += i + ":" +a[i] + "\n"; } alert(all); };'); $repl->execute('all_a()'); $repl->execute('a[3].click()'); <>;

That's good but not satisfying, especially if I want to explore deeper data contained in the DOM, and that's why I thought to use MozRepl::RemoteObject, in addition to MozRepl. So, after reading the manual of MozRepl::RemoteObject, I proceed as follow, to connect the two modules :

#!/usr/bin/perl -w use strict; use warnings; use MozRepl; use MozRepl::RemoteObject; my $repl = MozRepl->new; $repl->setup({ log => [qw/ error info /], plugins => { plugins => [qw[ JSON2 ]] }, }); my $bridge = MozRepl::RemoteObject->install_bridge(repl => $repl); <>;

But, at this stage, I have the following error message :
"command timed-out at C:/Perl/site/lib/MozRepl/Client.pm line 186"
and the script dies.
I reproduced this result with Windows XP and with Linux Debian Squeeze.
I try to make a script working for now several weeks, and I didn't manage to automate tasks with firefox. I wonder if I should not give up.
Is it the right way to do what I want ?
Thank's for any information that could help me.
cf006


In reply to Problem using MozRepl and MozRepl::RemoteObject by cf006

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.