<?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>blogging and scraping &#187; watir</title>
	<atom:link href="http://www.tsnpc.com/tag/watir/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tsnpc.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Jul 2010 22:54:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>pay attention to attach the IE window when elements not found by watir</title>
		<link>http://www.tsnpc.com/pay-attention-to-attach-the-ie-window-when-elements-not-found-by-watir/</link>
		<comments>http://www.tsnpc.com/pay-attention-to-attach-the-ie-window-when-elements-not-found-by-watir/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 01:29:46 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[attach]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=178</guid>
		<description><![CDATA[Several times I spend several hours to identify an element, the element is there, but watir can not find it. I click a link and a new IE window comes up, and forget to attach the new IE window, so watir and me are looking for elements on different windows.]]></description>
			<content:encoded><![CDATA[<p>Several times I spend several hours to identify an element, the element is there, but watir can not find it.</p>
<p>I click a link and a new IE window comes up, and forget to attach the new IE window, so watir and me are looking for elements on different windows.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/pay-attention-to-attach-the-ie-window-when-elements-not-found-by-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refresh a browser using watir</title>
		<link>http://www.tsnpc.com/reflash-a-browser-using-watir/</link>
		<comments>http://www.tsnpc.com/reflash-a-browser-using-watir/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 20:43:06 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[refresh]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=149</guid>
		<description><![CDATA[Bellow is the code to refresh a browser using watir: ie77.refresh Related Blogs Related Blogs on watir Watir Podcast 7: Bret Pettichord (Watir Lead Developer) on FireWatir]]></description>
			<content:encoded><![CDATA[<p>Bellow is the code to refresh a browser using watir:</p>
<p>ie77.refresh<br />
<h4>Related Blogs</h4>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>watir</b></li>
<li><a href="http://watirpodcast.com/bret-pettichord-on-firewatir/"><b>Watir</b> Podcast 7: Bret Pettichord (<b>Watir</b> Lead Developer) on FireWatir</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/reflash-a-browser-using-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Choose a value from select box by watir</title>
		<link>http://www.tsnpc.com/choose-a-value-from-select-box-by-watir/</link>
		<comments>http://www.tsnpc.com/choose-a-value-from-select-box-by-watir/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 01:46:09 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[select_list]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=147</guid>
		<description><![CDATA[Bellow is the code to choose the second option from a select box: ie77.select_list(:class,&#8217;inputboxb&#8217;).select_item_in_select_list(:index,1) Related Blogs Related Blogs on select_list Related Blogs on watir Watir Podcast 7: Bret Pettichord (Watir Lead Developer) on FireWatir]]></description>
			<content:encoded><![CDATA[<p>Bellow is the code to choose the second option from a select box:</p>
<p>ie77.select_list(:class,&#8217;inputboxb&#8217;).select_item_in_select_list(:index,1)<br />
<h4>Related Blogs</h4>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>select_list</b></li>
</ul>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>watir</b></li>
<li><a href="http://watirpodcast.com/bret-pettichord-on-firewatir/"><b>Watir</b> Podcast 7: Bret Pettichord (<b>Watir</b> Lead Developer) on FireWatir</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/choose-a-value-from-select-box-by-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send data into an inner html of iframe by watir</title>
		<link>http://www.tsnpc.com/send-data-into-an-inner-html-of-iframe-by-watir/</link>
		<comments>http://www.tsnpc.com/send-data-into-an-inner-html-of-iframe-by-watir/#comments</comments>
		<pubDate>Sat, 25 Oct 2008 16:24:08 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[innerpage]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=146</guid>
		<description><![CDATA[I tried to input data to the inner html of iframe by watir for several months, and posted questions to many forums but got no answer. Yesterday an idea came into my mind, and I found a solution, following is the code: ie77.frame(:id, /Editor/).document.body.innertext = &#8220;good and better&#8221; Related Blogs Related Blogs on iframe Ajax [...]]]></description>
			<content:encoded><![CDATA[<p>I tried to input data to the inner html of iframe by watir for several months, and posted questions to many forums but got no answer.</p>
<p>Yesterday an idea came into my mind, and I found a solution, following is the code:</p>
<p>ie77.frame(:id, /Editor/).document.body.innertext = &#8220;good and better&#8221;<br />
<h4>Related Blogs</h4>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>iframe</b></li>
<li><a href="http://manikandanmv.wordpress.com/2008/10/24/ajax-file-upload/">Ajax File Upload</a></li>
</ul>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>innerpage</b></li>
</ul>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>watir</b></li>
<li><a href="http://watirpodcast.com/bret-pettichord-on-firewatir/"><b>Watir</b> Podcast 7: Bret Pettichord (<b>Watir</b> Lead Developer) on FireWatir</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/send-data-into-an-inner-html-of-iframe-by-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>$ Use the text property to locate a link in watir $</title>
		<link>http://www.tsnpc.com/use-the-text-property-to-locate-a-link-in-watir/</link>
		<comments>http://www.tsnpc.com/use-the-text-property-to-locate-a-link-in-watir/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 00:49:44 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[link]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=141</guid>
		<description><![CDATA[I found by chance that we can use the text property to locate a link in watir, the following is the syntax I used: ie77.link(:text =&#62; /the text in a link/).click Related Blogs Related Blogs on link Weekend Link Love Palin off message on North Korea? Related Blogs on watir Watir Podcast 7: Bret Pettichord [...]]]></description>
			<content:encoded><![CDATA[<p>I found by chance that we can use the text property to locate a link in watir, the following is the syntax I used:</p>
<p>ie77.link(:text =&gt; /the text in a link/).click<br />
<h4>Related Blogs</h4>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>link</b></li>
<li><a href="http://www.marksdailyapple.com/weekend-link-love-19/">Weekend <b>Link</b> Love</a></li>
<li><a href="http://embeds.blogs.foxnews.com/2008/10/11/palin-off-message-on-north-korea/">Palin off message on North Korea?</a></li>
</ul>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <b>watir</b></li>
<li><a href="http://watirpodcast.com/bret-pettichord-on-firewatir/"><b>Watir</b> Podcast 7: Bret Pettichord (<b>Watir</b> Lead Developer) on FireWatir</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/use-the-text-property-to-locate-a-link-in-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Close all other browser in watir</title>
		<link>http://www.tsnpc.com/close-all-other-browser-in-watir/</link>
		<comments>http://www.tsnpc.com/close-all-other-browser-in-watir/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 00:03:23 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=117</guid>
		<description><![CDATA[I used to close some browsers by following code: puts &#8220;to close a certain previous browser&#8221; Watir::IE.attach(:title, /google/).close puts &#8220;to close a certain previous browser&#8221; Watir::IE.attach(:title, /Internet/).close puts &#8220;to close a certain previous browser&#8221; Watir::IE.attach(:title, /Internet/).close but when 2 or more watir programs run together, they stalled there. I don&#8217;t know the reason, so I [...]]]></description>
			<content:encoded><![CDATA[<p>I used to close some browsers by following code:</p>
<p>puts &#8220;to close a certain previous browser&#8221;<br />
Watir::IE.attach(:title, /google/).close<br />
puts &#8220;to close a certain previous browser&#8221;<br />
Watir::IE.attach(:title, /Internet/).close<br />
puts &#8220;to close a certain previous browser&#8221;<br />
Watir::IE.attach(:title, /Internet/).close</p>
<p>but when 2 or more watir programs run together, they stalled there. I don&#8217;t know the reason, so I tried the following code which worked ok:</p>
<p>sleep 1<br />
puts &#8220;to close all the other browsers&#8221;<br />
ie77.close_others<br />
sleep 1<br />
puts &#8220;to close current browser&#8221;<br />
ie77.close</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/close-all-other-browser-in-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Append text to text_field at watir</title>
		<link>http://www.tsnpc.com/append-text-to-text_field-at-watir/</link>
		<comments>http://www.tsnpc.com/append-text-to-text_field-at-watir/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 20:32:22 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=74</guid>
		<description><![CDATA[At watir we can submit texts to forms by such a code like : ie.text_field.set(), we could also append texts by the code such as ie.text_field.append(), following is an example: require &#8216;watir&#8217; include Watir # Initialize the text to be submitted to a bbs conts = [] File.open(&#8216;goodword.txt&#8217;) do &#124;f&#124; f.each_line{&#124;l&#124; conts &#60;&#60; l} end [...]]]></description>
			<content:encoded><![CDATA[<p>At watir we can submit texts to forms by such a code like : ie.text_field.set(), we could also append texts by the code such as ie.text_field.append(), following is an example:</p>
<p>require &#8216;watir&#8217;<br />
include Watir</p>
<p># Initialize the text to be submitted to a bbs<br />
conts = []<br />
File.open(&#8216;goodword.txt&#8217;) do |f|<br />
f.each_line{|l| conts &lt;&lt; l}<br />
end<br />
#Initialize the advertising text to be appended<br />
advs = []<br />
File.open(&#8216;adv.txt&#8217;) do |f|<br />
f.each_line{|l| advs &lt;&lt; l}<br />
end<br />
&#8212;&#8212;&#8212;<br />
ie22.text_field(:name, &#8216;co&#8217;).set(conts[rand(conts.size)])<br />
ie22.text_field(:name, &#8216;co&#8217;).append(&#8220;\n&#8221;)<br />
ie22.text_field(:name, &#8216;co&#8217;).append(&#8220;\n&#8221;)<br />
ie22.text_field(:name, &#8216;co&#8217;).append(&#8220;\n&#8221;)<br />
ie22.text_field(:name, &#8216;co&#8217;).append(&#8220;\n&#8221;)<br />
ie22.text_field(:name, &#8216;co&#8217;).append(advs[rand(advs.size)])</p>
<p>&#8212;&#8211;</p>
<p>&#8220;\n&#8221;Â Â Â Â  means change to a new line.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/append-text-to-text_field-at-watir/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>use watir for Page scraping</title>
		<link>http://www.tsnpc.com/use-watir-for-page-scraping/</link>
		<comments>http://www.tsnpc.com/use-watir-for-page-scraping/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 14:23:54 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[scraping]]></category>

		<guid isPermaLink="false">http://www.tsnpc.com/?p=61</guid>
		<description><![CDATA[The following is the code to use watir for Page scraping: require &#8216;watir&#8217; include Watir jinan = &#8220;http://homemsg.focus.cn/msgview/607/48996344.html&#8221; ie21 = IE.new ie21.goto jinanba puts ie21.table(:index =&#62; 9, :class =&#62; /p9/).text #puts ie21.table(:index =&#62; 11, :class =&#62; /p9/).html The following is the code to use firewatir for Page scraping, the reson to use firewatir is that [...]]]></description>
			<content:encoded><![CDATA[<p>The following is the code to use watir for Page scraping:</p>
<p>require &#8216;watir&#8217;<br />
include Watir</p>
<p>jinan = &#8220;http://homemsg.focus.cn/msgview/607/48996344.html&#8221;</p>
<p>ie21 = IE.new<br />
ie21.goto jinanba</p>
<p>puts ie21.table(:index =&gt; 9, :class =&gt; /p9/).text</p>
<p>#puts ie21.table(:index =&gt; 11, :class =&gt; /p9/).html</p>
<p>The following is the code to use firewatir for Page scraping, the reson to use firewatir is that the watir will wait for the page load:</p>
<p>require &#8216;firewatir&#8217;<br />
include FireWatir</p>
<p>jinanba = &#8220;http://homemsg.focus.cn/msgview/607/48996344.html&#8221;</p>
<p>ie21 = Firefox.new<br />
ie21.goto jinanba</p>
<p>fout = File.new(&#8220;test.txt&#8221;, &#8220;w&#8221;)<br />
fout.puts ie21.table(:index , 16).html<br />
fout.close</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/use-watir-for-page-scraping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>$ The notes for watir $</title>
		<link>http://www.tsnpc.com/the-notes-for-watir/</link>
		<comments>http://www.tsnpc.com/the-notes-for-watir/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 23:59:49 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://tsnpc.com/?p=16</guid>
		<description><![CDATA[Developing Test Cases 1. Open an editor 2. take the .rb as your file extention 3. put the â€œrequire â€˜watirâ€™â€ into the first line 4.æ‰“å¼€æµè§ˆå™¨å¹¶è½¬åˆ°è¦æµ‹è¯•çš„åº”ç”¨ 5.ä¸Žä¹‹äº¤äº’å¹¶è®¾è®¡ä½ çš„testcase 6.åœ¨æµ‹è¯•è„šæœ¬ä¸­ä½¿ç”¨Watiræ–¹æ³• 7.éªŒè¯ç»“æžœ Interacting With a Web Page When Watir is used as a test script, the interaction with a web page is realized by submitting message to the element [...]]]></description>
			<content:encoded><![CDATA[<p>Developing Test Cases</p>
<p>1. Open an editor<br />
2. take the .rb as your file extention<br />
3. put the â€œrequire â€˜watirâ€™â€ into the first line<br />
4.æ‰“å¼€æµè§ˆå™¨å¹¶è½¬åˆ°è¦æµ‹è¯•çš„åº”ç”¨<br />
5.ä¸Žä¹‹äº¤äº’å¹¶è®¾è®¡ä½ çš„testcase<br />
6.åœ¨æµ‹è¯•è„šæœ¬ä¸­ä½¿ç”¨Watiræ–¹æ³•<br />
7.éªŒè¯ç»“æžœ</p>
<p>Interacting With a Web Page<br />
When Watir is used as a test script, the interaction with a web page is realized by submitting message to the element on the web page:</p>
<p>ie.text_field(:name , â€œqâ€).set(â€bluescorpioâ€)<br />
ie.button(:value , â€œClick Meâ€).click</p>
<p>Watir Syntax<br />
1.ä½¿ç”¨Watirå·¥å…·ï¼Œéœ€è¦åœ¨è„šæœ¬ä¸­åŠ ä¸Š<br />
require â€˜watirâ€™</p>
<p>2.åˆ›å»ºä¸€ä¸ªIEçš„æµ‹è¯•å®žä¾‹<br />
ie = Watir::IE.new<br />
æˆ–è€…åœ¨åˆ›å»ºçš„åŒæ—¶ç›´æŽ¥è½¬åˆ°é¡µé¢<br />
ie = Watir::IE.start(â€http://mytestsiteâ€)<br />
Watirä½¿ç”¨startæ–¹æ³•åŒæ—¶åˆ›å»ºä¸€ä¸ªæµè§ˆå™¨å®žä¾‹å¹¶è½¬åˆ°ä¸€ä¸ªé¡µé¢ã€‚</p>
<p>3. Web navigation<br />
ie.goto(â€http://mytestsiteâ€)</p>
<p>4.æ“çºµWebé¡µé¢å¯¹è±¡<br />
4.1è¶…é“¾æŽ¥<br />
4.1.1ä½¿ç”¨Textå±žæ€§ç‚¹å‡»è¶…é“¾æŽ¥<br />
ie.link(:text , â€œPickaxeâ€).click<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š<br />
&lt;a href=&#8221;http://pragmaticprogrammer.com/titles/ruby/&#8221;&gt;Pickaxe&lt;/a&gt;<br />
4.1.2ä½¿ç”¨URLå±žæ€§ç‚¹å‡»è¶…é“¾æŽ¥<br />
ie.link(:url , â€œhttp://pragmaticprogrammer.com/titles/ruby/â€).click<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š<br />
&lt;a href=&#8221;http://pragmaticprogrammer.com/titles/ruby/&#8221;&gt;Test Site&lt;/a&gt;</p>
<p>4.2å¤é€‰æ¡†<br />
4.2.1ä½¿ç”¨nameå±žæ€§è®¾ç½®å¤é€‰æ¡†<br />
ie.checkbox(:name, â€œcheckmeâ€).set<br />
4.2.2ä½¿ç”¨nameå±žæ€§æ¸…é™¤å¤é€‰æ¡†<br />
ie.checkbox(:name, â€œcheckmeâ€).clear<br />
4.2.3ä½¿ç”¨nameå’Œvalueå±žæ€§è®¾ç½®å¤é€‰æ¡†<br />
ie.checkbox(:name, â€œcheckmeâ€, â€œ1â€³).set<br />
4.2.4ä½¿ç”¨nameå’Œvalueå±žæ€§æ¸…é™¤å¤é€‰æ¡†<br />
ie.checkbox(:name, â€œcheckmeâ€, â€œ1â€³).clear<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;input maxlength=&#8221;67108863&#8243; name=&#8221;checkme&#8221; size=&#8221;20&#8243; type=&#8221;checkbox&#8221; value=&#8221;1&#8243; /&gt;</p>
<p>4.3å•é€‰æ¡†<br />
4.3.1ä½¿ç”¨nameå±žæ€§è®¾ç½®å•é€‰æ¡†<br />
ie.radio(:name, â€œclickmeâ€).set<br />
4.3.2ä½¿ç”¨nameå±žæ€§æ¸…é™¤å•é€‰æ¡†<br />
ie.radio(:name, â€œclickmeâ€).clear<br />
4.3.3ä½¿ç”¨nameå’Œidå±žæ€§è®¾ç½®å•é€‰æ¡†<br />
ie.radio(:name, â€œclickmeâ€, â€œ1â€³).set<br />
4.3.4ä½¿ç”¨nameå’Œidå±žæ€§æ¸…é™¤å•é€‰æ¡†<br />
ie.radio(:name, â€œclickmeâ€, â€œ1â€³).clear<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;input id=&#8221;1&#8243; maxlength=&#8221;67108863&#8243; name=&#8221;clickme&#8221; size=&#8221;20&#8243; type=&#8221;radio&#8221; value=&#8221;on&#8221; /&gt;</p>
<p>4.4ä¸‹æ‹‰æ¡†<br />
4.4.1ä½¿ç”¨nameå±žæ€§å’Œå€¼æ¥è®¾ç½®ä¸‹æ‹‰æ¡†<br />
ie.select_list( :name , â€œselectmeâ€).select(â€is funâ€)<br />
4.4.2ä½¿ç”¨nameå±žæ€§å’Œå€¼æ¥æ¸…é™¤ä¸‹æ‹‰æ¡†<br />
ie.select_list( :name , â€œselectmeâ€).clearSelection<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;select name=&#8221;selectme&#8221;&gt; &lt;option selected=&#8221;65535&#8243;&gt;&lt;/option&gt;&lt;option&gt;Web Testing&lt;/option&gt;&lt;option&gt;in Ruby&lt;/option&gt;&lt;option&gt;is fun&lt;/option&gt;&lt;/select&gt;</p>
<p>4.5åœ¨Webé¡µé¢ä¸­è¾“å…¥æ•°æ®</p>
<p>4.5.1ä½¿ç”¨æ–‡æœ¬è¾“å…¥æ¡†çš„é‚£ä¹ˆå±žæ€§è®¾ç½®è¾“å…¥å†…å®¹<br />
ie.text_field(:name, â€œtypeinmeâ€).set(â€Watir Worldâ€)<br />
4.5.2æ¸…ç©ºæ–‡æœ¬è¾“å…¥æ¡†<br />
ie.text_field(:name, â€œtypeinmeâ€).clear<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;input maxlength=&#8221;67108863&#8243; name=&#8221;typeinme&#8221; size=&#8221;20&#8243; type=&#8221;text&#8221; /&gt;</p>
<p>4.6ä»ŽWebé¡µé¢ä¸Šæäº¤æ•°æ®<br />
4.6.1æŒ‰é’®<br />
4.6.1.1é€šè¿‡å€¼æˆ–æ ‡é¢˜å±žæ€§ç‚¹å‡»æŒ‰é’®<br />
ie.button(:value, â€œClick Meâ€).click<br />
4.6.1.2é€šè¿‡nameå±žæ€§ç‚¹å‡»æŒ‰é’®<br />
ie.button(:name, â€œclickmeâ€).click</p>
<p>å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;input maxlength=&#8221;67108863&#8243; name=&#8221;clickme&#8221; size=&#8221;20&#8243; type=&#8221;button&#8221; value=&#8221;Click Me&#8221; /&gt;</p>
<p>4.6.2 Forms<br />
4.6.2.1 buttons in the forms<br />
using value or titleÂ Â Â Â Â  ie.button(:value, â€œSubmitâ€).click<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;form action=&#8221;submit&#8221; accept-charset=&#8221;UNKNOWN&#8221; enctype=&#8221;application/x-www-form-urlencoded&#8221; method=&#8221;post&#8221;&gt; &lt;input maxlength=&#8221;67108863&#8243; size=&#8221;20&#8243; type=&#8221;submit&#8221; value=&#8221;Submit&#8221; /&gt;&lt;/form&gt;4.6.2.2è¡¨å•ä¸­çš„å›¾ç‰‡æŒ‰é’®<br />
ä½¿ç”¨é‚£ä¹ˆå±žæ€§<br />
ie.button(:name, â€œdoitâ€).click<br />
following are the corresponding HTML codesï¼š</p>
<p>&lt;form action=&#8221;submit&#8221; accept-charset=&#8221;UNKNOWN&#8221; enctype=&#8221;application/x-www-form-urlencoded&#8221; method=&#8221;post&#8221;&gt; &lt;input maxlength=&#8221;67108863&#8243; name=&#8221;doit&#8221; size=&#8221;20&#8243; src=&#8221;http://www.gnpc.cn/wp-admin/images/doit.gif&#8221; type=&#8221;image&#8221; /&gt;&lt;/form&gt;4.6.2.3æ²¡æœ‰æŒ‰é’®çš„è¡¨å•<br />
Watir can submit a form by identifying it by its name, action and method attributes.<br />
å¯ä»¥é€šè¿‡nameã€actionä»¥åŠmethodå±žæ€§æ¥æäº¤è¡¨å•<br />
ie.form(:name, â€œloginformâ€).submit<br />
ie.form(:action, â€œloginâ€).submit<br />
å¯¹åº”çš„HTMLä»£ç ä¸ºï¼š</p>
<p>&lt;form action=&#8221;login&#8221; accept-charset=&#8221;UNKNOWN&#8221; enctype=&#8221;application/x-www-form-urlencoded&#8221; method=&#8221;get&#8221;&gt; &lt;input maxlength=&#8221;67108863&#8243; name=&#8221;username&#8221; size=&#8221;20&#8243; type=&#8221;text&#8221; /&gt;&lt;/form&gt;4.6.3æ¡†æž¶<br />
ie.show_frameså¯ä»¥æ‰“å°å‡ºå½“å‰é¡µé¢æ¡†æž¶çš„æ•°é‡å’Œåç§°<br />
Watirå…è®¸é€šè¿‡åç§°å±žæ€§æ¥è®¿é—®æ¡†æž¶ï¼Œå¦‚ie.frame(â€menuâ€)<br />
å¦‚æžœè¦è®¿é—®menuæ¡†æž¶ä¸­çš„ä¸€ä¸ªè¶…é“¾æŽ¥ï¼Œå¯ä»¥ie.frame(â€menuâ€).link(:text, â€œClick Menu Itemâ€).click</p>
<p>4.6.4 embedded frame<br />
ie.frame(â€frame1â€³).frame(:name, â€œnested_frameâ€)</p>
<p>4.6.5æ–°çª—å£<br />
ä¸€äº›Webåº”ç”¨ä¼šå¼¹å‡ºæ–°çª—å£æˆ–æ‰“å¼€ä¸€ä¸ªæ–°çª—å£ï¼Œå¯ä»¥ä½¿ç”¨attachæ–¹æ³•æ¥è®¿é—®å¹¶æŽ§åˆ¶æ–°çª—å£ã€‚é€šè¿‡æ ‡ç¤ºæ–°çª—å£çš„URLæˆ–è€…titleæ¥è®¿é—®ã€‚<br />
ie2 = Watir::IE.attach(:url, â€˜http://mytestsiteâ€™)<br />
ie3 = Watir::IE.attach(:title, â€˜Test New Windowâ€™)<br />
Regx is also an alternativeÂ Â Â  ie4 = Watir::IE.attach(:title, /Test New/)<br />
æ³¨æ„ï¼šä¸è¦æŠŠæ–°çª—å£åˆ†é…åˆ°ä½ çš„ieå˜é‡ï¼Œæœ€å¥½ç»™æ–°çª—å£ä¸€ä¸ªä¸åŒçš„åå­—</p>
<p>5. verify the test result<br />
æ¯”è¾ƒå¥½çš„æ–¹æ³•æ˜¯åœ¨æµ‹è¯•æ¡ˆä¾‹ä¸­å‡å¦‚éªŒè¯ç‚¹<br />
5.1å¯¹è±¡å­˜åœ¨<br />
ä½¿ç”¨Watiræ–¹æ³•contains_text<br />
ie.contains_text(â€Reached test verification point.â€)</p>
<p>if ie.contains_text(â€Reached test verification point.â€)<br />
puts: â€œTest passed. Page contains the text: Reached test verification point.â€<br />
else<br />
puts: â€œTest failed! Page didnâ€™t contain text: Reached test verification point.â€<br />
end</p>
<p>5.2 using test::unit Assertions<br />
5.2.1éœ€è¦test::unit<br />
require â€˜test/unitâ€™</p>
<p>5.2.2åˆ›å»ºæµ‹è¯•å®žä¾‹<br />
class TC_myTest &amp;lt; Test::Unit::TestCase<br />
â€¦fill in Test Case methods hereâ€¦<br />
end</p>
<p>5.2.3åˆ›å»ºæµ‹è¯•ç”¨ä¾‹æ–¹æ³•<br />
åœ¨æµ‹è¯•ç±»ä¸­ï¼Œéœ€è¦å£°æ˜Žè±¡ä¸‹é¢çš„æ–¹æ³•ï¼š<br />
def test_myTestCase<br />
fill in method body with Watir code and assertion here<br />
end</p>
<p>æ–¹æ³•å¿…é¡»ä»¥testå¼€å¤´ï¼Œrubyä¼šéšæœºè¿è¡Œæµ‹è¯•æ¡ˆä¾‹ï¼Œå¦‚æžœéœ€è¦é¡ºåºæ‰§è¡Œï¼Œéœ€è¦åœ¨teståŽåŠ ä¸Šå­—æ¯æˆ–æ•°å­—æ¥å¼ºè¿«å®ƒé¡ºåºæ‰§è¡Œï¼Œæ¯”å¦‚â€œtest_a_mytestâ€</p>
<p>å®šä¹‰æµ‹è¯•æ–¹æ³•çš„ç±»ï¼š<br />
class TC_myTest &amp;lt; Test::Unit::TestCase<br />
def test_ myTestCase<br />
Watir code and assertion hereâ€¦<br />
end<br />
def test_anotherTestCase<br />
Watir code and assertion hereâ€¦<br />
end<br />
def test_aTestCase<br />
Watir code and assertion hereâ€¦<br />
end<br />
end</p>
<p>5.2.4 Using Assertions<br />
Watiré€šè¿‡åœ¨ä¸€ä¸ªasertè¦†å†™Watiræ–¹æ³•æ”¯æŒassertionsã€‚<br />
assert(ie.contains_text(â€Reached test verification point.â€))</p>
<p>5.2.5Setup and Teardown<br />
def setup<br />
fill in code that will run before every test case hereâ€¦<br />
end<br />
def teardown<br />
fill in code that will run after every test case hereâ€¦<br />
end</p>
<p>6.Tips and Tricks<br />
Running Tests With the Browser Not Visible<br />
Run the tests with a â€œ-bâ€ option if you donâ€™t want the browser to be visible. ex. myTest.rb -b</p>
<h4>Related Blogs</h4>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <strong>watir</strong></li>
<li><a href="http://watirpodcast.com/bret-pettichord-on-firewatir/"><strong>Watir</strong> Podcast 7: Bret Pettichord (<strong>Watir</strong> Lead Developer) on FireWatir</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tsnpc.com/the-notes-for-watir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
