<?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</title>
	<atom:link href="http://justaddwatir.com/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. firefox-bin quit unexpectedly ?</title>
		<link>http://justaddwatir.com/2009/q-firefox-bin-quit-unexpectedly/</link>
		<comments>http://justaddwatir.com/2009/q-firefox-bin-quit-unexpectedly/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 02:44:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://altentee.com/watir/?p=54</guid>
		<description><![CDATA[If you are trying to run Firewatir on Mac OSX and you see the following error message
"firefox-bin quit unexpectedly"
Have a look at the detailed error message available from an irb terminal e.g.

$  irb
&#62;&#62;require 'firewatir'
=&#62; true
&#62;&#62; browser &#124;&#124; Firefox.new
dyld: Library not loaded: /usr/lib/libsqlite3.dylib
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Reason: Incompatible library version: Security requires version 9.0.0 [...]]]></description>
			<content:encoded><![CDATA[<p>If you are trying to run Firewatir on Mac OSX and you see the following error message</p>
<p>"firefox-bin quit unexpectedly"</p>
<p>Have a look at the detailed error message available from an irb terminal e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$  irb
&gt;&gt;require 'firewatir'
=&gt; true
&gt;&gt; browser || Firefox.new
dyld: Library not loaded: /usr/lib/libsqlite3.dylib
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Reason: Incompatible library version: Security requires version 9.0.0 or later, but libsqlite3.dylib provides version 1.0.0</pre></div></div>

<p>Chances are you have the wrong version of libsqlite3 in your Firefox installation. Run the following commands to copy the correct libraries into Firefox.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ mv /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib.orig
$ cp /usr/lib/libsqlite3.dylib /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2009/q-firefox-bin-quit-unexpectedly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I integrate watir with TestLink?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-integrate-watir-with-testlink/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-integrate-watir-with-testlink/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 11:11:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[firewatir]]></category>
		<category><![CDATA[watir]]></category>
		<category><![CDATA[testlink]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=51</guid>
		<description><![CDATA[A. This requires several hacks and use of the developer API ...

The first step to integrating these products is to download and install
TestLink 1.8.0 BETA2
Once finished, add the TestLink API BETA
Their blog has installation instructions for both.
Regarding the API there are a number of changes you will need to ensure:
1. create api_developer_keys table using the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. This requires several hacks and use of the developer API ...</strong><br />
<span id="more-51"></span><br />
The first step to integrating these products is to download and install<br />
<a href="http://testlink.org/wordpress/download/">TestLink 1.8.0 BETA2</a><br />
Once finished, add the <a href="http://testlink.org/wordpress/2007/11/19/testlink-api-beta/">TestLink API BETA</a></p>
<p>Their blog has installation instructions for both.</p>
<p>Regarding the API there are a number of changes you will need to ensure:<br />
1. create <strong>api_developer_keys</strong> table using the <strong>api_sql_changes.sql</strong> included with the API<br />
2. create an api developer key in your new <strong>api_developer_keys</strong> table<br />
3. update the <strong>api.const.inc.php</strong> database constants<br />
4. <code>$ chmod -R 755 api/</code><br />
5. change the paths to relevant libraries in <strong>xmlrpc.php</strong>, mine looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">change xmlrpc<span style="color: #339933;">.</span>php
<span style="color: #009933; font-style: italic;">/**
 * IXR is the class used for the XML-RPC server
 */</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/../third_party/xml-rpc/class-IXR.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;api.const.inc.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// require_once(&quot;APIErrors.php&quot;);</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/../config.inc.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/../lib/functions/common.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/../lib/functions/testproject.class.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/../lib/functions/testcase.class.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/../lib/functions/testsuite.class.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can be creative as you want with the API. The way I implemented this, was to change the test execution template to allow corresponding test cases to be executed within watir such that the following calls are made:</p>
<p>TestLink -> test_harness.php -> test_harness.rb -> test_suite.rb</p>
<p>I had to first modify the TestLink <strong>gui/templates/execute/execSetResults.tpl</strong> template as per the following (approx line 544):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">if</span> <span style="color: #000088;">$tc_exec</span><span style="color: #339933;">.</span>can_be_executed<span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">include</span> <span style="color: #990000;">file</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;execute/inc_exec_controls.tpl&quot;</span>
               args_input_enable_mgmt<span style="color: #339933;">=</span><span style="color: #000088;">$input_enabled_disabled</span>
               args_tcversion_id<span style="color: #339933;">=</span><span style="color: #000088;">$tcversion_id</span>
               args_webeditor<span style="color: #339933;">=</span><span style="color: #000088;">$gui</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exec_notes_editors</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$tc_id</span><span style="color: #009900;">&#93;</span>
               args_labels<span style="color: #339933;">=</span><span style="color: #000088;">$labels</span><span style="color: #009900;">&#125;</span>
      <span style="color: #339933;">&lt;!--</span>ADDED BY tim<span style="color: #339933;">.</span>koopmans<span style="color: #339933;">@</span>90kts<span style="color: #339933;">.</span>com<span style="color: #339933;">--&gt;</span>
      <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">include</span> <span style="color: #990000;">file</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;execute/inc_exec_watir.tpl&quot;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>I then added a new TestLink template in <strong>gui/templates/execute/inc_exec_watir.tpl</strong> as per the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #339933;">*</span>
TestLink Open Source Project <span style="color: #339933;">-</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//testlink.sourceforge.net/</span>
<span style="color: #000088;">$Id</span><span style="color: #339933;">:</span> inc_exec_watir<span style="color: #339933;">.</span>tpl<span style="color: #339933;">,</span>v <span style="color:#800080;">0.1</span> <span style="color: #cc66cc;">2008</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">15</span> <span style="color: #208080;">05</span><span style="color: #339933;">:</span><span style="color: #208080;">03</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">53</span> $
Purpose<span style="color: #339933;">:</span> draw execution controls <span style="color: #b1b100;">for</span> watir based test cases
Author <span style="color: #339933;">:</span> tim<span style="color: #339933;">.</span>koopmans<span style="color: #339933;">@</span>90kts<span style="color: #339933;">.</span>com
<span style="color: #339933;">*</span><span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#123;</span>assign <span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ResultsStatusCode&quot;</span> value<span style="color: #339933;">=</span><span style="color: #000088;">$tlCfg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">results</span><span style="color: #339933;">.</span>status_code<span style="color: #009900;">&#125;</span>
  		<span style="color: #339933;">&lt;</span>table <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;invisible&quot;</span><span style="color: #339933;">&gt;</span>
  		<span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;</span>
  			<span style="color: #339933;">&lt;</span>th rowspan<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text-align: center;&quot;</span><span style="color: #339933;">&gt;</span>
  				<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">&gt;</span>Watir Test <span style="color: #b1b100;">Case</span> <span style="color: #009900;">&#123;</span><span style="color: #000088;">$tc_id</span><span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://localhost/~koops/testlink/watir/test_harness.php?name={<span style="color: #006699; font-weight: bold;">$tc_exec</span>.name}&amp;id=<span style="color: #006699; font-weight: bold;">{$gui-&gt;tcasePrefix}</span>{<span style="color: #006699; font-weight: bold;">$tc_exec</span>.tc_external_id}&amp;tcid=<span style="color: #006699; font-weight: bold;">{$tc_id}</span>&quot;</span><span style="color: #339933;">&gt;</span>Execute <span style="color: #339933;">&amp;</span>rarr<span style="color: #339933;">;&lt;/</span>a<span style="color: #339933;">&gt;</span>
  			<span style="color: #339933;">&lt;/</span>th<span style="color: #339933;">&gt;</span>
  			<span style="color: #339933;">&lt;</span>td valign<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;top&quot;</span> style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;width: 30%;&quot;</span><span style="color: #339933;">&gt;</span>
    			<span style="color: #339933;">&lt;/</span>td<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;/</span>tr<span style="color: #339933;">&gt;</span>
  		<span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This essentially adds a new link to the test execution screen which will call a test_harness from PHP using a system call. The screen mod looks like this:<br />
<a href='http://justaddwatir.com/watir/wp-content/uploads/2008/10/exectest.png'><img src="http://justaddwatir.com/watir/wp-content/uploads/2008/10/exectest.png" alt="" title="exectest" width="500" height="245" class="alignleft size-full wp-image-52" /></a> The PHP harness which it calls is located in <strong>watir/test_harness.php</strong> and looks like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tcid&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$tcid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tcid&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Executing watir test case id: <span style="color: #006699; font-weight: bold;">$tcid</span>&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ruby /Users/koops/Sites/testlink/watir/test_harness.rb <span style="color: #006699; font-weight: bold;">$id</span> <span style="color: #006699; font-weight: bold;">$tcid</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The purpose of this is to launch a test_harness client in Ruby passing it the client ID and test case ID required for execution. This client is based on the API examples and it could have been written in PHP, but I felt more comfortable with Ruby. So there is a little double handling here which could be improved... The Ruby harness it calls is located in <strong>watir/test_harness.rb</strong> and looks like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'xmlrpc/client'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> TestlinkAPIClient
  <span style="color:#008000; font-style:italic;"># substitute your server URL Here</span>
  SERVER_URL = <span style="color:#996600;">&quot;http://localhost/~koops/testlink/api/xmlrpc.php&quot;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>dev_key<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@server</span> = <span style="color:#6666ff; font-weight:bold;">XMLRPC::Client</span>.<span style="color:#9900CC;">new2</span><span style="color:#006600; font-weight:bold;">&#40;</span>SERVER_URL<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@devKey</span> = dev_key
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> reportTCResult<span style="color:#006600; font-weight:bold;">&#40;</span>tcid, tpid, status<span style="color:#006600; font-weight:bold;">&#41;</span>
    args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;devKey&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>@devKey, <span style="color:#996600;">&quot;tcid&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>tcid, <span style="color:#996600;">&quot;tpid&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>tpid, <span style="color:#996600;">&quot;status&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>status<span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0066ff; font-weight:bold;">@server</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tl.reportTCResult&quot;</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> getProjectIDByClientID<span style="color:#006600; font-weight:bold;">&#40;</span>clientid<span style="color:#006600; font-weight:bold;">&#41;</span>
    args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;devKey&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>@devKey<span style="color:#006600; font-weight:bold;">&#125;</span>
    result = <span style="color:#0066ff; font-weight:bold;">@server</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tl.getProjects&quot;</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
    result.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>project<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> projectid = project<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;id&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> project<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;name&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{clientid}/</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">'ERROR: Unable to find project by client id: '</span> <span style="color:#006600; font-weight:bold;">+</span> clientid
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> getProjectTestPlanIDByName<span style="color:#006600; font-weight:bold;">&#40;</span>testprojectid, testplanname<span style="color:#006600; font-weight:bold;">&#41;</span>
    args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;devKey&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>@devKey, <span style="color:#996600;">&quot;testprojectid&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>testprojectid<span style="color:#006600; font-weight:bold;">&#125;</span>
    result = <span style="color:#0066ff; font-weight:bold;">@server</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tl.getProjectTestPlans&quot;</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
    result.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>testplanid, values<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">p</span> values
      <span style="color:#0000FF; font-weight:bold;">return</span> testplanid <span style="color:#9966CC; font-weight:bold;">if</span> values<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;name&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{testplanname}/</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">'ERROR: Unable to find test plan name by test project id '</span> <span style="color:#006600; font-weight:bold;">+</span> testprojectid
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> getProjectTestPlanID<span style="color:#006600; font-weight:bold;">&#40;</span>testprojectid<span style="color:#006600; font-weight:bold;">&#41;</span>
    args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;devKey&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>@devKey, <span style="color:#996600;">&quot;testprojectid&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>testprojectid<span style="color:#006600; font-weight:bold;">&#125;</span>
    result = <span style="color:#0066ff; font-weight:bold;">@server</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tl.getProjectTestPlans&quot;</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
    result.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>testplanid, values<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> testplanid
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">'ERROR: Unable to find test plan id '</span> <span style="color:#006600; font-weight:bold;">+</span> testprojectid
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> getTestCaseIDByName<span style="color:#006600; font-weight:bold;">&#40;</span>testcasename<span style="color:#006600; font-weight:bold;">&#41;</span>
    args = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">&quot;devKey&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>@devKey, <span style="color:#996600;">&quot;testcasename&quot;</span><span style="color:#006600; font-weight:bold;">=&gt;</span>testcasename<span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0066ff; font-weight:bold;">@server</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tl.getTestCaseIDByName&quot;</span>, args<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># param args</span>
watirid  = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">&quot;ID74278-1&quot;</span>
tcid     = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006666;">62</span>
clientid = watirid<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>\w\d<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+/</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># execute watir test suite</span>
stdout = <span style="color:#006600; font-weight:bold;">%</span>x<span style="color:#006600; font-weight:bold;">&#91;</span>ruby <span style="color:#006600; font-weight:bold;">/</span>Users<span style="color:#006600; font-weight:bold;">/</span>koops<span style="color:#006600; font-weight:bold;">/</span>Sites<span style="color:#006600; font-weight:bold;">/</span>testlink<span style="color:#006600; font-weight:bold;">/</span>watir<span style="color:#006600; font-weight:bold;">/</span>test_suite.<span style="color:#9900CC;">rb</span> <span style="color:#006600; font-weight:bold;">--</span>name test_<span style="color:#008000; font-style:italic;">#{tcid}]</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> stdout
status = <span style="color:#996600;">&quot;f&quot;</span>
status = <span style="color:#996600;">&quot;p&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> stdout =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006666;">0</span> errors<span style="color:#006600; font-weight:bold;">/</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># substitute your Dev Key Here</span>
client = TestlinkAPIClient.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;f2a979d533cdd9761434bba60a88e4d8&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># find a project id by client id [custom]</span>
projectid = client.<span style="color:#9900CC;">getProjectIDByClientID</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Client #{clientid}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># find the first test plan id for a given project id [native]</span>
tpid = client.<span style="color:#9900CC;">getProjectTestPlanID</span><span style="color:#006600; font-weight:bold;">&#40;</span>projectid<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
result = client.<span style="color:#9900CC;">reportTCResult</span><span style="color:#006600; font-weight:bold;">&#40;</span>tcid.<span style="color:#9900CC;">to_i</span>, tpid, status<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Run ID: &quot;</span> <span style="color:#006600; font-weight:bold;">+</span> result<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;id&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;&lt;br/&gt;&quot;</span></pre></div></div>

<p>This harness essentially calls  a corresponding Test::Unit test suite (by test case ID) and returns the results using the XML-RPC client back into TestLink.<br />
To give you an idea, my example test suite looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'test/unit'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'firewatir'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">include</span> FireWatir
<span style="color:#9966CC; font-weight:bold;">class</span> TestSuite <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Test::Unit::TestCase</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> setup
    <span style="color:#0066ff; font-weight:bold;">@b</span>=Firefox.<span style="color:#9900CC;">new</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> test_62
    <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://www.google.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>So, stitching it all together, TestLink can call watir test cases using the test case ID which is unique to TestLink and passing it to the relevant test runner or harness in Ruby. Ruby then does the execution and feeds the results (pass/fail) using the XML-RPC client API back into TestLink. You end up with test results being tracked in TestLink and presented (in progress) like this:<br />
<a href='http://justaddwatir.com/watir/wp-content/uploads/2008/10/testcaseexecution.png'><img src="http://justaddwatir.com/watir/wp-content/uploads/2008/10/testcaseexecution.png" alt="" title="testcaseexecution" width="500" height="291" class="alignnone size-full wp-image-53" /></a><br />
It's all a bit hacky and would be happy for others to progress with this. Just some ideas to get you started =)</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-integrate-watir-with-testlink/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Q. How do I install watir standalone?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-install-watir-standalone/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-install-watir-standalone/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 02:47:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[installation]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=50</guid>
		<description><![CDATA[A previous post highlights some ways in which you can install watir from behind a proxy server via the command line.
This approach can be problematic when using authenticated proxy servers. The following file is a simple MSI which will install Watir 1.5.6 with its required dependencies. The pre-requisites for this MSI are:
1. Ruby 1.8.6 installed [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://justaddwatir.com/watir/q-how-do-i-gem-install-watir-behind-a-proxy-server/">previous post</a> highlights some ways in which you can install watir from behind a proxy server via the command line.</p>
<p>This approach can be problematic when using authenticated proxy servers. The following file is a simple MSI which will install Watir 1.5.6 with its required dependencies. The pre-requisites for this MSI are:<br />
1. Ruby 1.8.6 installed to c:\ruby<br />
2. Windows XP SP2 (I have not tried this on Windows Vista)</p>
<p><strong><a href="http://justaddwatir.com/watir/wp-content/uploads/watir_156.msi">Download MSI</a></strong></p>
<p>Note: this is not the preferred way of installing Watir and as such I cannot offer any guarantees on its success.</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-install-watir-standalone/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Q. How do I use ci_reporter in my Test::Unit scripts?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-use-ci_reporter-in-my-testunit-scripts/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-use-ci_reporter-in-my-testunit-scripts/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 10:28:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[ci_reporter]]></category>
		<category><![CDATA[Test::Unit]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=49</guid>
		<description><![CDATA[A. Use a ci_reporter gem ...
To install the ci_reporter gem on windows:

gem install ci_reporter

If you're using Test::Unit, ensure the ci/reporter/rake/test_unit_loader.rb file is loaded before the test is run. If you're using RSpec, you‘ll need to pass the following arguments to the spec command:

 --require GEM_PATH/lib/ci/reporter/rake/rspec_loader
 --format CI::Reporter::RSpec

You may also want to set the output directory [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use a ci_reporter gem ...</strong><br />
To install the ci_reporter gem on windows:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">gem install ci_reporter</pre></div></div>

<p>If you're using Test::Unit, ensure the ci/reporter/rake/test_unit_loader.rb file is loaded <strong>before</strong> the test is run. If you're using RSpec, you‘ll need to pass the following arguments to the spec command:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"> <span style="color:#006600; font-weight:bold;">--</span><span style="color:#CC0066; font-weight:bold;">require</span> GEM_PATH<span style="color:#006600; font-weight:bold;">/</span>lib<span style="color:#006600; font-weight:bold;">/</span>ci<span style="color:#006600; font-weight:bold;">/</span>reporter<span style="color:#006600; font-weight:bold;">/</span>rake<span style="color:#006600; font-weight:bold;">/</span>rspec_loader
 <span style="color:#006600; font-weight:bold;">--</span><span style="color:#CC0066; font-weight:bold;">format</span> <span style="color:#6666ff; font-weight:bold;">CI::Reporter::RSpec</span></pre></div></div>

<p>You may also want to set the output directory as demonstrated by setting the CI_REPORTS environment variable.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'test/unit'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'ci/reporter/rake/test_unit_loader.rb'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'watir'</span>
ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;CI_REPORTS&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'C:/temp/'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-use-ci_reporter-in-my-testunit-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I pass command line arguments to Test::Unit?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-pass-command-line-arguments-to-testunit/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-pass-command-line-arguments-to-testunit/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 09:45:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[Test::Unit]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=48</guid>
		<description><![CDATA[A. Use the -- argument to stop processing Test::Unit specific arguments ...
Module Test::Unit has its own command line arguments as specified by the following:

~/just_add_watir $&#62;ruby test_suite.rb --help
Test::Unit automatic runner.
Usage: test/unit/graph_test.rb [options] [-- untouched arguments]
&#160;
    -r, --runner=RUNNER              Use the given [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the -- argument to stop processing Test::Unit specific arguments ...</strong><br />
Module Test::Unit has its own command line arguments as specified by the following:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">~/just_add_watir $&gt;ruby test_suite.rb --help
Test::Unit automatic runner.
Usage: test/unit/graph_test.rb [options] [-- untouched arguments]
&nbsp;
    -r, --runner=RUNNER              Use the given RUNNER.
                                     (c[onsole], f[ox], g[tk], g[tk]2, t[k])
    -n, --name=NAME                  Runs tests matching NAME.
                                     (patterns may be used).
    -t, --testcase=TESTCASE          Runs tests in TestCases matching TESTCASE.
                                     (patterns may be used).
    -v, --verbose=[LEVEL]            Set the output level (default is verbose).
                                     (s[ilent], p[rogress], n[ormal], v[erbose])
     --                           Stop processing options so that the
                                     remaining options will be passed to the
                                     test.
    -h, --help                       Display this help.
&nbsp;
Deprecated options:
        --console                    Console runner (use --runner).
        --gtk                        GTK runner (use --runner).
        --fox                        Fox runner (use --runner).</pre></div></div>

<p>Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> test_0021
  <span style="color:#008000; font-style:italic;"># need to call test unit with -- argument</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;argument 1 is: &quot;</span>,ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-pass-command-line-arguments-to-testunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I execute arbitrary javascript?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-execute-arbitrary-javascript/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-execute-arbitrary-javascript/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 09:31:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.goto]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=47</guid>
		<description><![CDATA[A. Use the .goto method to call the javascript ...
Example html:

&#60;html lang=&#34;en-US&#34; xmlns=&#34;http://www.w3.org/1999/xhtml&#34; xml:lang=&#34;en-US&#34;&#62;
  &#60;body scroll=&#34;no&#34;&#62;
    &#60;script type=&#34;text/javascript&#34; charset=&#34;utf-8&#34;&#62;
      function openWin(i){
         alert(i);
      }
    &#60;/script&#62;
    &#60;div id=&#34;menuLayer1&#34;&#62;
  [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the .goto method to call the javascript ...</strong><br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0020.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;">html</span> <span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en-US&quot;</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en-US&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> scroll<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;no&quot;</span>&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> <span style="color: #000066;">charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span>
      function openWin(i){
         alert(i);
      }
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuLayer1&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuLite1&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuFg1&quot;</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuItem1&quot;</span> mmaction<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;location='javascript:openWin(2);'&quot;</span> zIndex<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuItemText1&quot;</span>&gt;</span>
              <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuItemShim1&quot;</span>&gt;</span>
                <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">align</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;left&quot;</span>&gt;</span>
                  just_add_watir
                <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
              <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</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_0020.html'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">div</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:id</span>, <span style="color:#996600;">&quot;menuItem1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">flash</span>
<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;">&quot;javascript:openWin(2)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-execute-arbitrary-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I learn all the objects on a page? [firewatir]</title>
		<link>http://justaddwatir.com/2008/how-do-i-learn-all-the-objects-on-a-page-firewatir/</link>
		<comments>http://justaddwatir.com/2008/how-do-i-learn-all-the-objects-on-a-page-firewatir/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 21:45:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[firewatir]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[objects]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=46</guid>
		<description><![CDATA[Sometimes you might wish to implement a QTP-like 'object repository'. I've had most success implementing this via Ruby modules.
To 'learn' all the objects on a page using firewatir you can use a simple script like this:

require 'rubygems'
require 'firewatir'
&#160;
class NilClass
  def length
    0
  end
end
&#160;
class DiscoverObjects
  include FireWatir
&#160;
  def initialize&#40;url&#41;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you might wish to implement a QTP-like 'object repository'. I've had most success implementing this via Ruby modules.</p>
<p>To 'learn' all the objects on a page using firewatir you can use a simple script like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'firewatir'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">NilClass</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> length
    <span style="color:#006666;">0</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> DiscoverObjects
  <span style="color:#9966CC; font-weight:bold;">include</span> FireWatir
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> url
      <span style="color:#008000; font-style:italic;"># attach to specific url</span>
      <span style="color:#0066ff; font-weight:bold;">@b</span> = Firefox.<span style="color:#9900CC;">start</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#008000; font-style:italic;"># attach to existing window</span>
      <span style="color:#0066ff; font-weight:bold;">@b</span> = Firefox.<span style="color:#9900CC;">new</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> all
    <span style="color:#0066ff; font-weight:bold;">@objects</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:links</span>, <span style="color:#ff3333; font-weight:bold;">:text_fields</span>, <span style="color:#ff3333; font-weight:bold;">:buttons</span>, <span style="color:#ff3333; font-weight:bold;">:select_lists</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>type<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span>type<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>element<span style="color:#006600; font-weight:bold;">|</span>
        <span style="color:#0066ff; font-weight:bold;">@objects</span><span style="color:#006600; font-weight:bold;">&#91;</span>element<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
        <span style="color:#0066ff; font-weight:bold;">@objects</span><span style="color:#006600; font-weight:bold;">&#91;</span>element<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:type</span><span style="color:#006600; font-weight:bold;">&#93;</span> = type.<span style="color:#9900CC;">to_s</span><span style="color:#006600; font-weight:bold;">&#91;</span>0..<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>
        <span style="color:#008000; font-style:italic;"># omitted :href, :url, :class</span>
        <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span>, <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:value</span>, <span style="color:#ff3333; font-weight:bold;">:text</span>, <span style="color:#ff3333; font-weight:bold;">:index</span>, <span style="color:#ff3333; font-weight:bold;">:xpath</span>, <span style="color:#ff3333; font-weight:bold;">:title</span>, <span style="color:#ff3333; font-weight:bold;">:action</span>, <span style="color:#ff3333; font-weight:bold;">:src</span>, <span style="color:#ff3333; font-weight:bold;">:for</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>attrib<span style="color:#006600; font-weight:bold;">|</span>
          value = element.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span>attrib<span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#0066ff; font-weight:bold;">@objects</span><span style="color:#006600; font-weight:bold;">&#91;</span>element<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>attrib<span style="color:#006600; font-weight:bold;">&#93;</span> = value <span style="color:#9966CC; font-weight:bold;">unless</span> value.<span style="color:#9900CC;">empty</span>?
        <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>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> print_objects
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;module #{@b.title.to_s.gsub(/[^<span style="color:#000099;">\d</span><span style="color:#000099;">\w</span>]/,'').capitalize}&quot;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;# Objects learned from: #{@b.url}<span style="color:#000099;">\n</span># #{Time.now}&quot;</span>
&nbsp;
    <span style="color:#0066ff; font-weight:bold;">@objects</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>key,val<span style="color:#006600; font-weight:bold;">|</span>
      val.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>k,v<span style="color:#006600; font-weight:bold;">|</span>
          <span style="color:#9966CC; font-weight:bold;">unless</span> k.<span style="color:#9900CC;">to_s</span> =~ <span style="color:#006600; font-weight:bold;">/</span>type<span style="color:#006600; font-weight:bold;">/</span>
            method_name = <span style="color:#996600;">&quot;#{val[:type]}_#{k}_#{v.to_s.gsub(/[^<span style="color:#000099;">\d</span><span style="color:#000099;">\w</span>]/,'_').downcase}&quot;</span>
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span>def #{method_name.gsub('__','_').gsub(/_$/,'')}&quot;</span>
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span><span style="color:#000099;">\t</span>return @b.#{val[:type]}(:#{k}, <span style="color:#000099;">\&quot;</span>#{v}<span style="color:#000099;">\&quot;</span>)<span style="color:#000099;">\n</span><span style="color:#000099;">\t</span>end<span style="color:#000099;">\n</span><span style="color:#000099;">\n</span>&quot;</span>
          <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>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;end&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
url = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>
discover = DiscoverObjects.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
discover.<span style="color:#9900CC;">all</span>
discover.<span style="color:#9900CC;">print_objects</span></pre></div></div>

<p>Which will produce results like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> Firefoxwebbrowserfastermoresecurecustomizable
<span style="color:#008000; font-style:italic;"># Objects learned from: http://www.mozilla.com/en-US/firefox/</span>
<span style="color:#008000; font-style:italic;"># Sat Sep 27 07:40:08 +1000 2008</span>
	<span style="color:#9966CC; font-weight:bold;">def</span> link_text_qmo
		<span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:text</span>, <span style="color:#996600;">&quot;QMO&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> link_text_press_center
		<span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:text</span>, <span style="color:#996600;">&quot;Press Center&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
	<span style="color:#9966CC; font-weight:bold;">def</span> link_text_other_systems_and_languages
		<span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:text</span>, <span style="color:#996600;">&quot;Other Systems and Languages&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
	<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Feel free to modify to suit (for watir or the like). I develop on a Mac, so firewatir is easiest for me. The manual way is to just use the IE Developer Toolbar or Firebug depending on your platform.</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/how-do-i-learn-all-the-objects-on-a-page-firewatir/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Q. How do I enter the current date or time into a textfield?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-enter-the-current-date-or-time-into-a-textfield/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-enter-the-current-date-or-time-into-a-textfield/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 17:19:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[Time.now]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=45</guid>
		<description><![CDATA[A. Use the Time.now method ...
Example html:

&#60;html&#62;
   &#60;body&#62;
      &#60;form method=&#34;post&#34; action=&#34;&#34;&#62;
         &#60;textarea name=&#34;comments&#34; cols=&#34;40&#34; rows=&#34;1&#34;&#62;
            Enter your comments here...
         &#60;/textarea&#62;&#60;br /&#62;
 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the Time.now method ...</strong><br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0200/test_0103.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;">html</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comments&quot;</span> <span style="color: #000066;">cols</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #000066;">rows</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span>&gt;</span>
            Enter your comments here...
         <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">t=<span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>
<span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>,<span style="color:#996600;">&quot;comments&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span>t.<span style="color:#9900CC;">strftime</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;%m/%d/%Y_%H%:M%&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-enter-the-current-date-or-time-into-a-textfield/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I get the text displayed in a javascript popup?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-get-the-text-displayed-in-a-javascript-popup/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-get-the-text-displayed-in-a-javascript-popup/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 13:04:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.ControlGetText]]></category>
		<category><![CDATA[autoit]]></category>
		<category><![CDATA[popup]]></category>
		<category><![CDATA[win32OLE]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=44</guid>
		<description><![CDATA[A. Use the WIN32OLE extension library with the autoit function library ...
You will need to install autoit. You can download it here, once installed you can call the function library using the win32OLE extension library.
Example html:

&#60;html&#62;
   &#60;head&#62;
   &#60;script language=&#34;javascript&#34;&#62;
      function msgbox (textstring) {
    [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the WIN32OLE extension library with the autoit function library ...</strong><br />
You will need to install autoit. You can download it <a href=http://www.autoitscript.com/autoit3/>here</a>, once installed you can call the function library using the win32OLE extension library.<br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0006.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;">html</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span>&gt;</span>
      function msgbox (textstring) {
      alert (textstring) }
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;test_00test_0107&quot;</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text1&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span>text&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span>button <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;show me&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;msgbox(form.text1.value)&quot;</span>&gt;</span>
     <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</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:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'watir'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'win32ole'</span>
autoit = WIN32OLE.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'AutoItX3.Control'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<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_0101_0200/test_0107.html'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">text_field</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>,<span style="color:#996600;">&quot;text1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;This is the text in the popup&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">button</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span>,<span style="color:#996600;">&quot;submit&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">click_no_wait</span>
autoit.<span style="color:#9900CC;">WinWaitActive</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;[Class:#32770]&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
text = autoit.<span style="color:#9900CC;">ControlGetText</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;[Class:#32770]&quot;</span>, <span style="color:#996600;">&quot;&quot;</span>, <span style="color:#996600;">&quot;Static2&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
autoit.<span style="color:#9900CC;">ControlClick</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;[Class:#32770]&quot;</span>,<span style="color:#996600;">&quot;&quot;</span>,<span style="color:#996600;">&quot;Button1&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> text</pre></div></div>

<p>In order for the autoit function to execute, you need to use the .click_no_wait method in watir before the autoit function. This is because once the pop up is presented, the focus comes off the IE window and the script will pause. The .click_no_wait tells the script to continue running regardless of what happens next.<br />
You may use the autoit window identifier to get the properties of the pop up the static text.</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-get-the-text-displayed-in-a-javascript-popup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I attach to a current IE session?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-attach-to-a-current-ie-session/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-attach-to-a-current-ie-session/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 12:53:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.attach]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=43</guid>
		<description><![CDATA[A. Use the .attach method...
Example watir:

@b=Watir::IE.attach&#40;:title,//&#41;

I have used regex here for the window title, you can be more specific if you like.
]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the .attach method...</strong><br />
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:#6666ff; font-weight:bold;">Watir::IE</span>.<span style="color:#9900CC;">attach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:title</span>,<span style="color:#006600; font-weight:bold;">//</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>I have used regex here for the window title, you can be more specific if you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-attach-to-a-current-ie-session/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
