<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Avoiding brittle Selenium tests</title>
	<atom:link href="http://www.kongsli.net/nblog/2007/03/22/avoiding-brittle-selenium-tests/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kongsli.net/nblog/2007/03/22/avoiding-brittle-selenium-tests/</link>
	<description>Deep thoughts on shallow topics</description>
	<lastBuildDate>Mon, 16 Jan 2012 00:36:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: vidarkongsli</title>
		<link>http://www.kongsli.net/nblog/2007/03/22/avoiding-brittle-selenium-tests/comment-page-1/#comment-6438</link>
		<dc:creator>vidarkongsli</dc:creator>
		<pubDate>Thu, 10 Dec 2009 06:51:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=19#comment-6438</guid>
		<description>&lt;p&gt;Hi Lyle,&lt;/p&gt;

&lt;p&gt;This is quite a conundrum, but I have an idea what might be the issue. I think that you have more than one element on your page that contains &#039;phone&#039;, and that Selenium matches the first one it finds, which happen not to be the input field. (In addition to the input element itself, there is a span element which Id contains &#039;phone&#039;).&lt;/p&gt;

&lt;p&gt;If this is the case, there are two possible solutions:&lt;/p&gt;

&lt;p&gt;1) Use a partial Id which is unique, for instance &#039;aspx1_phone&#039; to make sure that the input field is mached&lt;/p&gt;

&lt;p&gt;2) Try to change the partialId extension to use the XPath expression &lt;code&gt;ends-with(s1, s2)&lt;/code&gt; instead of &lt;code&gt;contains(s1, s2)&lt;/code&gt;. If this works, there is only one Id on your page that matches &#039;phone&#039;. Then, the extension would be:
&lt;code&gt;PageBot.prototype.locateElementByPartialId = function(text, inDocument) {
    return this.locateElementByXPath(&quot;//*[ends-with(./@id, &#039;Z&#039;)][1]&quot;.replace(/Z/,text), inDocument);
};&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Cheers,
Vidar&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Lyle,</p>

<p>This is quite a conundrum, but I have an idea what might be the issue. I think that you have more than one element on your page that contains &#8216;phone&#8217;, and that Selenium matches the first one it finds, which happen not to be the input field. (In addition to the input element itself, there is a span element which Id contains &#8216;phone&#8217;).</p>

<p>If this is the case, there are two possible solutions:</p>

<p>1) Use a partial Id which is unique, for instance &#8216;aspx1_phone&#8217; to make sure that the input field is mached</p>

<p>2) Try to change the partialId extension to use the XPath expression <code>ends-with(s1, s2)</code> instead of <code>contains(s1, s2)</code>. If this works, there is only one Id on your page that matches &#8216;phone&#8217;. Then, the extension would be:
<code>PageBot.prototype.locateElementByPartialId = function(text, inDocument) {
    return this.locateElementByXPath("//*[ends-with(./@id, 'Z')][1]".replace(/Z/,text), inDocument);
};</code></p>

<p>Cheers,
Vidar</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Lyle</title>
		<link>http://www.kongsli.net/nblog/2007/03/22/avoiding-brittle-selenium-tests/comment-page-1/#comment-6383</link>
		<dc:creator>Lyle</dc:creator>
		<pubDate>Tue, 08 Dec 2009 19:03:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=19#comment-6383</guid>
		<description>&lt;p&gt;I added your partialId user extension to my user-extensions.js file. I have had success with most fields, but failure with others. For example, if you visit the page http://www.connectionsacademy.com/home.aspx and click on the link at the top left page labeled &quot;Request Information&quot; you get a RadWindow Frame pop-up. I select the frame and then start entering data in the form using a script I created with Selenium IDE and FireFox 3.5.4. The first name, last name, address and city fields all enter their data using the type command similar to the following:&lt;/p&gt;

&lt;p&gt;&quot; type &#124; partialId=firstName &#124; bobFirstName &quot;&lt;/p&gt;

&lt;p&gt;However, the phone number field fails to enter the information into the field, but there are no errors in the IDE log and it continues to the next step in the test. Pasted below is the log from executing the script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;* [info] Executing: &#124;open &#124; /home.aspx &#124; &#124;
* [info] Executing: &#124;click &#124; partialId=requestInfoButton &#124; &#124;
* [info] Executing: &#124;selectFrame &#124; relative=up &#124; &#124;
* [info] Executing: &#124;type &#124; partialId=firstName &#124; First Name Field &#124;
* [info] Executing: &#124;type &#124; partialId=lastName &#124; Last Name Field &#124;
* [info] Executing: &#124;type &#124; partialId=addressLine1 &#124; Address Line 1Field &#124;
* [info] Executing: &#124;type &#124; partialId=addressLine2 &#124; Address Line 2 Field &#124;
* [info] Executing: &#124;type &#124; partialId=city &#124; City Field &#124;
* [info] Executing: &#124;select &#124; ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_state &#124; label=MD &#124;
* [info] Executing: &#124;type &#124; partialId=zipCode &#124; 21202 &#124;
* [info] Executing: &#124;type &#124; partialId=email &#124; lalbright@connectionsacademy.com &#124;
* [info] Executing: &#124;type &#124; partialId=phone &#124; 410-555-5555 &#124;
* [info] Executing: &#124;click &#124; ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_cbGradesGoingIntoK &#124; &#124;
* [info] Executing: &#124;select &#124; ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_childrenCurrentlyAttend &#124; label=Regular Public School &#124;
* [info] Executing: &#124;click &#124; ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_submit &#124; &#124;
* [info] Executing: &#124;selectFrame &#124; masterPageRadWindow &#124; &#124;
* [info] Executing: &#124;waitForTextPresent &#124; We will send you information shortly on our public school at home program. &#124; &#124; 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What&#039;s going wrong here?&lt;/p&gt;

&lt;p&gt;Also, can the partialId command be used with the Select command ... because if the answer is yes, I am having issues with that as well. Thanks for any help you can provide. I really appreciate the user extension. Nice work. :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I added your partialId user extension to my user-extensions.js file. I have had success with most fields, but failure with others. For example, if you visit the page <a href="http://www.connectionsacademy.com/home.aspx" rel="nofollow">http://www.connectionsacademy.com/home.aspx</a> and click on the link at the top left page labeled &#8220;Request Information&#8221; you get a RadWindow Frame pop-up. I select the frame and then start entering data in the form using a script I created with Selenium IDE and FireFox 3.5.4. The first name, last name, address and city fields all enter their data using the type command similar to the following:</p>

<p>&#8221; type | partialId=firstName | bobFirstName &#8220;</p>

<p>However, the phone number field fails to enter the information into the field, but there are no errors in the IDE log and it continues to the next step in the test. Pasted below is the log from executing the script:</p>

<pre><code>* [info] Executing: |open | /home.aspx | |
* [info] Executing: |click | partialId=requestInfoButton | |
* [info] Executing: |selectFrame | relative=up | |
* [info] Executing: |type | partialId=firstName | First Name Field |
* [info] Executing: |type | partialId=lastName | Last Name Field |
* [info] Executing: |type | partialId=addressLine1 | Address Line 1Field |
* [info] Executing: |type | partialId=addressLine2 | Address Line 2 Field |
* [info] Executing: |type | partialId=city | City Field |
* [info] Executing: |select | ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_state | label=MD |
* [info] Executing: |type | partialId=zipCode | 21202 |
* [info] Executing: |type | partialId=email | <a href="mailto:lalbright@connectionsacademy.com">lalbright@connectionsacademy.com</a> |
* [info] Executing: |type | partialId=phone | 410-555-5555 |
* [info] Executing: |click | ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_cbGradesGoingIntoK | |
* [info] Executing: |select | ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_childrenCurrentlyAttend | label=Regular Public School |
* [info] Executing: |click | ctl00_ctl00_ctl00_blankPageContent_masterPageContent_pageContent__control_customforms_requestinfo_ascx1_submit | |
* [info] Executing: |selectFrame | masterPageRadWindow | |
* [info] Executing: |waitForTextPresent | We will send you information shortly on our public school at home program. | | 
</code></pre>

<p>What&#8217;s going wrong here?</p>

<p>Also, can the partialId command be used with the Select command &#8230; because if the answer is yes, I am having issues with that as well. Thanks for any help you can provide. I really appreciate the user extension. Nice work. <img src='http://www.kongsli.net/nblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
	</item>
</channel>
</rss>

