<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>just_add_watir &#124; Advanced recipes for Watir &#187; .getElementsByTagName</title>
	<atom:link href="http://justaddwatir.com/tag/getelementsbytagname/feed/" rel="self" type="application/rss+xml" />
	<link>http://justaddwatir.com</link>
	<description>Advanced recipes for Watir</description>
	<lastBuildDate>Wed, 21 Oct 2009 02:44:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Q. How can extract information from script headers?</title>
		<link>http://justaddwatir.com/2008/q-how-can-extract-information-from-script-headers/</link>
		<comments>http://justaddwatir.com/2008/q-how-can-extract-information-from-script-headers/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 08:51:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.getElementsByTagName]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=38</guid>
		<description><![CDATA[A. Use the getElementsByTagName method and iterate through results ...
Example html:

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

Example watir:

@b.goto&#40;'http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0016.html'&#41;
s=&#91;&#93;
scripts = @b.document.body.parentElement.getElementsByTagName&#40;&#34;script&#34;&#41;
scripts.each do &#124;script_tag&#124;
  script_tag.invoke&#40;&#34;innerHTML&#34;&#41;.each do &#124;script&#124;
    if script.match&#40;/var PAGE_TID/&#41;
      puts script
    end
  end
end

]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the getElementsByTagName method and iterate through results ...</strong><br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0016.html">Example html</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>test_0016<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;generator&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;TextMate http://macromates.com/&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;author&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;koops&quot;</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- Date: 2008-08-12 --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>var PAGE_TID =&quot;cache;app05.qa.sfo1:8101;2008-08-07T18:38:30Z;0001&quot;;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">goto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0016.html'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
s=<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
scripts = <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">document</span>.<span style="color:#9900CC;">body</span>.<span style="color:#9900CC;">parentElement</span>.<span style="color:#9900CC;">getElementsByTagName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;script&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
scripts.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>script_tag<span style="color:#006600; font-weight:bold;">|</span>
  script_tag.<span style="color:#9900CC;">invoke</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;innerHTML&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>script<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> script.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>var PAGE_TID<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> script
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-can-extract-information-from-script-headers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
