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

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!

  • Comment on Re^2: Javascript variables access help with WWW::Mechanize::Firefox
  • Download Code

Replies are listed 'Best First'.
Re^3: Javascript variables access help with WWW::Mechanize::Firefox
by Anonymous Monk on Sep 29, 2016 at 00:34 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:

    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