Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: WWW::Mechanize - how to get the position of an element on my screen?

by Corion (Patriarch)
on Jan 31, 2012 at 19:22 UTC ( [id://951050]=note: print w/replies, xml ) Need Help??


in reply to Re^2: WWW::Mechanize - how to get the position of an element on my screen?
in thread WWW::Mechanize - how to get the position of an element on my screen?

You don't seem to understand. The "position" of an HTML element only exists if the HTML is actually rendered into a layout. HTML::Tree does not do such rendering.

  • Comment on Re^3: WWW::Mechanize - how to get the position of an element on my screen?

Replies are listed 'Best First'.
Re^4: WWW::Mechanize - how to get the position of an element on my screen?
by mascip (Pilgrim) on Jan 31, 2012 at 20:31 UTC

    That's an important point and i didn't know it, thank you Corion.

    Would it then be possible for me to pass my HTML::Element to Javascript? Does it make any sense?

    My aim being : finding the element with HTML::Tree, and then retrieving its position with Javascript.

      That's not how things work. Most likely, whatever Javascript or HTML rendering tool you use will also support XPath or CSS selectors. Use these tools instead.

        Thank you for this precious advice.
        I see two ways out of this:

        1. i start this mini-project all over again (it's very doable : at the moment i'm only doing tests to identify the tools i should use), using XPath instead of HTML::Tree. Which will allow me to use this ->element_coordinate() function from WWW::Mechanize::Firefox.

        2. i have found HTML::TreeBuilder::XPath which apparently enables to use both Trees and XPath. Could this enable me to use ->element_coordinates() from my tree nodes ?

        I'm trying solution 2. I've been fighting to get this to work, and finally got to a point where i identified my obstacle :
        Apparently, get_element_coordinate() takes a MozRepl::RemoteObject::Instance as an argument, and i didn't find how HTML::Tree::XPath could return me such an object from my HTML::Element tree node.

        If someone had a simple solution to this, great.
        Otherwize, i'll just start it again with XPAth. Which would be good for me to learn anyway.
        As you can see, i'm learning as i go, and there's lots i have to learn. Any book / tutorial / website for me to learn would be very welcome. I like book-learning more than all. As an indication, i read "Perl & LWP" and "Spidering Hacks" already. But neither of them addresses the DOM (i'm not even sure what it is), nor Javascript (i did two tutorials, but it's not enough), nor XPath in depth, nor... all the important things i forget.

        Thanks a lot for building this very useful library Corion, and for answering beginners' questions : it's very kind of you.
        Have a good day =o)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://951050]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-19 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found