Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by mascip (Pilgrim)
on Feb 01, 2012 at 23:24 UTC ( #951315=note: print w/ replies, xml ) Need Help??


in reply to Re^7: 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?

This morning I realized how stupid that was : i'm creating my Tree from the HTML content only, while the object position can be influenced by the Javascript (And other stuff? And something that manages the display layout i guess), which WWW::Mechanize::Firefox "takes into account" (simple words for beginner understanding).

I read it several times, i knew it but forgot it while doing this first test. I guess i hoped there could be a (bijective) correspondence between the two. And i made this mistake also because i was doing this first test on an example where there is no Javascript at all.

Next step for me : learn about XPath.
From what i remember it looks fairly much like a Tree. So i guess i could use similar algorithms. Any major difference ?

Thanks again for helping me understand :o)
Now i know where to look, which makes a big difference.


Comment on Re^8: WWW::Mechanize - how to get the position of an element on my screen?
Re^9: WWW::Mechanize - how to get the position of an element on my screen?
by Corion (Pope) on Feb 02, 2012 at 08:21 UTC

    XPath is "just" a query language for trees. When starting out with XPath, I found the analogy to paths in a directory tree helpfull. "*" works the same, "/" works the same. If you don't care about the intermediate directories, use //.

      Thank you ! Same algorithms, other language. Should be fairly simple =o)

      In my searches on internet, i found that Mozilla::Mechanize seems to do this another way. The elements it returns are Mozilla::DOM::HTMLElement, and it gets their position thanks to a QueryInstance.
      I don't know what a DOM:HTMLElement are, nor QueryInstance. I don't have the time to learn these now, and know that i want to use WWW::Mechanize::Firefox, so i could as well forget about it for now.

      I was just wondering if it was equivalent to using XPath in the end, and if a few words could make me understand.
      If not, it's all alright : i now know i should use XPath.
      And if i need to understand these, i'll read a book about it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-09-02 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls