1

I'm new to PhantomJS and not very good with Javascript to be honest. I'm looking to take a snapshot of a given website but only the selected dom element. So command wise it would look a little like

phantomjs http://fabieno.com #nav

And it would take a picture of the nav bar. Or whatever the selector selects. I guess it multiple existences exists then multiple snapshots would be necessary. Only problem is being so new it leaves me with a big ? in my head. Any help you guys could provide would be greatly appreciated.

From my research I have only really found. https://gist.github.com/n1k0/1501173

But I am unsure how it works or if it does want I am asking.

Kind regards,

Fab

Fabor
  • 567
  • 9
  • 21

1 Answers1

0

Since you should really only have one id attribute named nav you'll probably want to do this with classes. In which case have a look at getElementsByClassName and what you want to get is a collection of all the nav elements and loop through them performing your needed actions. See this for details JS: iterating over result of getElementsByClassName using Array.forEach

Community
  • 1
  • 1
Anthony Hatzopoulos
  • 10,437
  • 2
  • 40
  • 57