Aug
12
2008

Q. How can extract information from script headers?

A. Use the getElementsByTagName method and iterate through results …
Example html:

<title>test_0016</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="koops">
<!-- Date: 2008-08-12 -->
<script type="text/javascript">var PAGE_TID ="cache;app05.qa.sfo1:8101;2008-08-07T18:38:30Z;0001";
</script>

Example watir:

@b.goto('http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0016.html')
s=[] 
scripts = @b.document.body.parentElement.getElementsByTagName("script") 
scripts.each do |script_tag| 
  script_tag.invoke("innerHTML").each do |script| 
    if script.match(/var PAGE_TID/) 
      puts script
    end 
  end
end
Written by Tim Koopmans in: watir | Tags:

1 Comment »

  • Great work.

    Comment | October 28, 2008

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes