in reply to Javascript variables access help with WWW::Mechanize::Firefox

The DOM object where they are retained seems like an array, that is called Diary

In javascript, the "document" is called Window

To retrieve an an element object from the document, use xpath

  • Comment on Re: Javascript variables access help with WWW::Mechanize::Firefox

Replies are listed 'Best First'.
Re^2: Javascript variables access help with WWW::Mechanize::Firefox
by ray.rick.mini (Sexton) on Sep 29, 2016 at 00:19 UTC

    Hello, could you explain better what you mean with an xpath expression example? I already use xpath method on several parts of the script, but only for searching HTML elements in the page, not for values stored in js variables. I use for example:

    my $xpath= '//td[@class="test"]' ; ..

    and...thanks for your reply!

      Hello, could you explain better what you mean with an xpath expression example? I already use xpath method on several parts of the script, but only for searching HTML elements in the page, not for values stored in js variables. I use for example:

      The variable "window" is the DOM, its all the html elements that exist on the webpage you're on,

      The FireBug DOM panel and the HTML panel both represent "window", the current page, the current document , the current dom, the dom, dom

      So use the HTML panel, "Copy XPath", and give it to mechanize xpath method, to retrieve the object for the element of the text you're interested in

        Thanks to your suggestion now I'm able to extract wanted value. I didnt realize I can access dom values on xpath returned objects! That did the magic. I used:

        my $mode=$mech->xpath('//textarea[@id="12345"]'); print $mech->{value};

        I am still discovering the power of this module. Thanks for helping