<?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>Ing. Andrés Canavesi &#187; Java</title>
	<atom:link href="http://andrescanavesi.com.uy/blog/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrescanavesi.com.uy/blog</link>
	<description>Blog</description>
	<lastBuildDate>Sat, 05 May 2012 04:56:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Selenium with SmartClient (SmartGwt)</title>
		<link>http://andrescanavesi.com.uy/blog/using-selenium-with-smartclient-smartgwt/</link>
		<comments>http://andrescanavesi.com.uy/blog/using-selenium-with-smartclient-smartgwt/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 22:24:47 +0000</pubDate>
		<dc:creator>andres</dc:creator>
				<category><![CDATA[Configuración]]></category>
		<category><![CDATA[Desarrollo web]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Gwt]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SmartClient]]></category>
		<category><![CDATA[SmartGwt]]></category>
		<category><![CDATA[programación]]></category>
		<category><![CDATA[selenium]]></category>

		<guid isPermaLink="false">http://andrescanavesi.com.uy/blog/?p=461</guid>
		<description><![CDATA[
        Selenium is a powerful and popular tool which can be used to test your SmartClient applications.
        Selenium executes tests against your running application in a browser emulating user interaction and asserting various conditions.
        [...]]]></description>
			<content:encoded><![CDATA[<p>
        <a href="http://seleniumhq.org/">Selenium</a> is a powerful and popular tool which can be used to test your SmartClient applications.<br />
        Selenium executes tests against your running application in a browser emulating user interaction and asserting various conditions.<br />
        Selenium provides a record/playback tool for authoring tests without learning a test scripting language. You must be familiar with<br />
        <a href="http://seleniumhq.org/">Selenium</a> and use of <a href="http://seleniumhq.org/projects/ide/">Selenium IDE</a> before proceeding. Refer to the documentation on the <a href="http://seleniumhq.org/">Selenium</a></p>
<p>        site.
    </p>
<p>
        Use of Selenium with SmartClient applications is no different than using Selenium to write and run test cases with any other application with<br />
        the exception on on caveat. Selenium supports the concept of <a href="http://seleniumhq.org/docs/04_selenese_commands.html#locating-elements">Locators</a><br />
        in order to specify the element you&#8217;d like a given Selenium command to operate on. For example Selenium supports XPath based locators, and DOM ID based locators.<br />
        XPath based locators are extremely fragile due to complexity of certain highly nested DOM elements you need access to combined with the fact that<br />
        XPath support varies across browsers and so your tests might not work across different browsers.
    </p>
<p>
        SmartClient occasionally renders a different DOM structure depending on the browser for performance for rendering the UI such that it appears identical across various browsers.<br />
        As a result using DOM ID or DOM XPath based locators with SmartClient applications is not advisable. Instead SmartClient supports a new Selenium<br />
        locator which is an xpath-like string used by Selenium to robustly identify DOM elements within a SmartClient application. SmartClient locators for Selenium<br />
        are prefixed by &#8220;scLocator=&#8221; and have a readable XPath like value even for cells in ListGrid&#8217;s or TreeGrids. Typically these locators will not be hand-written and<br />
        are generated by <a href="http://seleniumhq.org/projects/ide/">Selenium IDE</a>, Selenium&#8217;s test recording tool.<br />
        One primary locator is based on the ID of the SmartClient widget and has the syntax <b>ID=&lt;Canvas ID&gt;</b>. This<br />
        simplifies the task of writing tests if you know the ID of the Canvas. For reference, the scLocator syntax for<br />
        ListGrid cells and DynamicForm FormItem&quot;s can be found at the end of this document.
    </p>
<h4>Setup Instructions</h4>
<ul>
<li>SmartClient ships with a Selenium user extension Javascript file : user-extensions.js. When running the Selenium tests make sure you place this file at the appropriate location.<br />
        Refer to the Selenium Documentation for mode details.
    </li>
<li>In order to create tests, we suggest you use Selenium IDE. By default, Selenium looks for a file called &#8220;user-extensions.js&#8221;, and loads the javascript code found in that file.<br />
        In the standard Selenium distribution, this file does not exist. You should place this file in this common location.<br />
        Refer to the Selenium documentation if you need additional information. Once you have<br />
        Selenium IDE installed, you will need to use the SmartClient user-extensions.js file with Selenium IDE. This is installed by<br />
        putting the pathname to its location on your computer in the Selenium Core extensions field of Selenium-IDEÕs Options=>Options=>General tab.<br />
        Additional Details on how this can be setup can be found <a href="http://seleniumhq.org/docs/08_user_extensions.html#using-user-extensions-with-selenium-ide">here</a>.
    </li>
<li>
        You will also need to configure Selenium IDE with a SmartClient provided Selenium IDE extensions javascript file : user-extensions-ide.js This is installed by<br />
        putting the pathname to its location on your computer in the Selenium IDE  extensions field of Selenium-IDEÕs Options=>Options=>General tab.
    </li>
</ul>
<p>That&#8217;s it, we&#8217;re done configuring the environment.</p>
<h4>Recording Selenium tests with Selenium IDE</h4>
<p>
        Once you have your application running in Firefox, open Selenium IDE from the Tools ==> Selenium IDE menu option. If the Selenium IDE is in record mode,<br />
        then clicking or carrying out other operations like typing in a text field with automatically record the appropriate Selenium commands with the SmartClient locator.<br />
        There&#8217;s no need for you to manually enter the locator, the recorder does this for you! Sometimes users many want finder grain control of what Selenium command<br />
        is created instead of having the Selenium IDE recorder do this automatically. For example if you want to verify the value of a particular cell in a ListGrid.<br />
        Instead on typing in the command &#8220;verifyTable&#8221; and manually enter the SmartClient Locator (scLocator), you can simply right click on the table cell or any other<br />
        SmartClient widget and the most suitable Selenium commands will appear in the context menu along with the scLocator path for the clicked element. See image below.
    </p>
<p>    <img src="selenium-ide-example.png"/></p>
<hr />
<p><h4><u>Common scLocator syntax</u></h4>
<h4><u>List Grid cells</u></h4>
<p>	<b>//ListGrid[ID="itemList"]/body/row[itemID=1996||itemName=Sugar White 1KG||SKU=85201400||1]/col[fieldName=SKU||1]</b></p>
<ul>
<li>This assumes the ListGrid has an explicit ID</li>
<li>the &#8216;body&#8217; part might be &#8216;frozenBody&#8217; if the field in question was frozen</li>
<li>row[......] identifies the row (record)
<li>itemID=<value> &#8211; that&#8217;s the primary key field from the dataSource the grid is bound to
<li>itemName=<value> &#8211; that&#8217;s the title field value for the record
<li>SKU=&#8230; &#8211; that&#8217;s the cell the user clicked&#8217;s value
<li>1 &#8211; that&#8217;s the index of the row (rowNum)
<li>col[.....] &#8211; identifies the column in the grid
<li>fieldName=&#8230; &#8211; field name for the field the user clicked
<li> 1 &#8211; that&#8217;s the index of the column
	</ul>
</p>
<p><h4><u>Form Items</u></h4>
<p>	<b>//DynamicForm[ID="autoTestForm"]/item[name=textField||title=textField||value=test||index=0||Class=TextItem]/element</b></p>
<p>This example is the data element (text entry box) for a text field </p>
<ul>
<li>this form has an explicit ID
<li>item[...] identifies the item
<li>name (field name, if set)
<li>title (title, if set)
<li>value (current value if set)
<li>index (index in the form items array)
<li>Class (SC class of the item &#8211; in this case TextItem) after the &#8220;/&#8221; we identify the part of the item in question options here include:
<li>&#8220;element&#8221; &#8211; the data element
<li>&#8220;canvas&#8221; &#8211; for CanvasItems &#8211; points to the canvas embedded in the item
<li>in this case the xpath might continue to contain, for example children of the canvas or elements within it (cells in a listGrid, etc)
<li>&#8220;textbox&#8221; &#8211; the &#8220;text box&#8221; &#8211; this is the area where content is written out for items without a &#8216;data element&#8217; &#8211; like header items
<li>&#8220;[icon=<...>]&#8221; &#8211; the icon element &#8212; &#8220;<...>&#8221; would contain the &#8220;name&#8221;<br />
	of the icon
	</ul>
</p>
<hr />
<p><h4><u>Known Limitations</u></h4>
<ul>
<li>Support for multi-select for SelectItems with selection mode &#8220;grid&#8221; (non-default)</li>
<li>Support for Drag &amp; Drop due to limitations in Selenium</li>
</ul>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://andrescanavesi.com.uy/blog/using-selenium-with-smartclient-smartgwt/" target="_blank"><img src="http://andrescanavesi.com.uy/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://andrescanavesi.com.uy/blog/using-selenium-with-smartclient-smartgwt/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://andrescanavesi.com.uy/blog/using-selenium-with-smartclient-smartgwt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java 4 ever</title>
		<link>http://andrescanavesi.com.uy/blog/java-4-ever/</link>
		<comments>http://andrescanavesi.com.uy/blog/java-4-ever/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 04:39:16 +0000</pubDate>
		<dc:creator>andres</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ocio]]></category>

		<guid isPermaLink="false">http://andrescanavesi.com.uy/blog/?p=432</guid>
		<description><![CDATA[


Share on Facebook]]></description>
			<content:encoded><![CDATA[<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/znTKuCyMrsk&amp;hl=es_ES&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/znTKuCyMrsk&amp;hl=es_ES&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object><br />
<br />
<img src="http://blogs.sun.com/manuelcr/resource/jpg/java-duke-guitar.png" alt="java" /></p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://andrescanavesi.com.uy/blog/java-4-ever/" target="_blank"><img src="http://andrescanavesi.com.uy/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://andrescanavesi.com.uy/blog/java-4-ever/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://andrescanavesi.com.uy/blog/java-4-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evento doble click en Java</title>
		<link>http://andrescanavesi.com.uy/blog/evento-doble-click-en-java/</link>
		<comments>http://andrescanavesi.com.uy/blog/evento-doble-click-en-java/#comments</comments>
		<pubDate>Thu, 21 May 2009 22:00:16 +0000</pubDate>
		<dc:creator>andres</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://andrescanavesi.com.uy/blog/?p=127</guid>
		<description><![CDATA[Este evento no está incorporado de forma nativa por lo que deberemos construirlo a mano utilizando el evento mouse clicked.
El siguiente ejemplo es aplicado sobre una jList pero puede usarse para cualquier otro tipo de componente, contenedor, etc. que soporte este evento.
jList.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					if(e.getClickCount()==2){
						System.out.println(&#8220;Se ha realizado un doble click&#8221;);
					}
				}
			});
Fuente
Share on Facebook]]></description>
			<content:encoded><![CDATA[<p>Este evento no está incorporado de forma nativa por lo que deberemos construirlo a mano utilizando el evento <strong>mouse clicked</strong>.<br />
El siguiente ejemplo es aplicado sobre una jList pero puede usarse para cualquier otro tipo de componente, contenedor, etc. que soporte este evento.</p>
<p>jList.addMouseListener(new java.awt.event.MouseAdapter() {<br />
				public void mouseClicked(java.awt.event.MouseEvent e) {<br />
					if(e.getClickCount()==2){<br />
						System.out.println(&#8220;Se ha realizado un doble click&#8221;);<br />
					}<br />
				}<br />
			});</p>
<p><a href="http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html">Fuente</a></p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://andrescanavesi.com.uy/blog/evento-doble-click-en-java/" target="_blank"><img src="http://andrescanavesi.com.uy/blog/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://andrescanavesi.com.uy/blog/evento-doble-click-en-java/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://andrescanavesi.com.uy/blog/evento-doble-click-en-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

