<?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>Agile Software Testing</title>
	<atom:link href="http://agilesoftwaretesting.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://agilesoftwaretesting.com</link>
	<description>Helping QA professionals in the world of Agile Software Development</description>
	<lastBuildDate>Thu, 19 Aug 2010 15:52:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Merging Hashes in Powershell</title>
		<link>http://agilesoftwaretesting.com/?p=133</link>
		<comments>http://agilesoftwaretesting.com/?p=133#comments</comments>
		<pubDate>Thu, 19 Aug 2010 15:52:51 +0000</pubDate>
		<dc:creator>Dima</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[hashtable]]></category>
		<category><![CDATA[merge]]></category>

		<guid isPermaLink="false">http://agilesoftwaretesting.com/?p=133</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sad to say this, but I was not able to find a default hash.merge command in powershell. So, after spending some time researching, i just had to bite the bullet and make my own function for merging. Hope this helps</p>
<blockquote><p>function Merge-Hash{<br />
param($parentHash, $childHash)</p>
<p>foreach ($childKey in $childHash.keys){<br />
$parentHash.$childKey = $childHash.$childKey<br />
}</p>
<p>return $parentHash<br />
}</p></blockquote>
<p>To test it, you can use this simple call in powershell</p>
<p>$hash1 = @{&#8220;a&#8221;=&#8221;1&#8243;;&#8221;b&#8221;=&#8221;2&#8243;;&#8221;c&#8221;=&#8221;3&#8243;}</p>
]]></content:encoded>
			<wfw:commentRss>http://agilesoftwaretesting.com/?feed=rss2&amp;p=133</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-threading with Powershell and PowershellASP V2</title>
		<link>http://agilesoftwaretesting.com/?p=118</link>
		<comments>http://agilesoftwaretesting.com/?p=118#comments</comments>
		<pubDate>Fri, 04 Jun 2010 03:48:56 +0000</pubDate>
		<dc:creator>Dima</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[background job]]></category>
		<category><![CDATA[parallel processes]]></category>
		<category><![CDATA[start-job]]></category>
		<category><![CDATA[Start-Process]]></category>

		<guid isPermaLink="false">http://agilesoftwaretesting.com/?p=118</guid>
		<description><![CDATA[The story: I have several powershell scripts that I want to trigger via website, these scripts will start doing a lot of things on different computers on my network. We chose to use PowershellASP as the website server app, that allows you to call PS scripts from withing the HTML. This product works great! Check [...]]]></description>
			<content:encoded><![CDATA[<p>The story:</p>
<p>I have several powershell scripts that I want to trigger via website, these scripts will start doing a lot of things on different computers on my network. We chose to use <a href="http://www.powershellinside.com/powershell/asp/default.aspx">PowershellASP</a> as the website server app, that allows you to call PS scripts from withing the HTML. This product works great! Check it out.</p>
<p>The Problem:</p>
<p>If you wish to invoke a command with PSASP, you just put in a PS snippet in HTML and your script is ran <img src='http://agilesoftwaretesting.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<blockquote><p><html></p>
<p><% Invoke-Command -ScriptBlock { Get-Services }</p>
<p></html></p></blockquote>
<p>You will be redirected to a page, which will have the output from your command. This is all good and great, but what if you want to do multiple tasks on multiple computers at the same time? Then you need to start some background jobs. However, it seems that background jobs only run in the current PS window, and if you close the window down, the job is terminated. This becomes a problem because you do not have a continuous window in PSASP, and as soon as you start the background process the ASP process is terminated and your job with it.</p>
<p>The Solution:</p>
<p>What you need to do is start a process Start-Process cmdlt. Keep in mind that start-process starts executables. So, we have to execute the powershell.exe and pass in a .ps1 file as an argument. This file will do our job for us J</p>
<p>Here is some code:</p>
<blockquote><p><%</p>
<p>$ps = "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe"</p>
<p>$working_dir = "C:\temp\ " #location of the ps.1 scripts to be executed</p>
<p>$script = ".\process.ps1"</p>
<p>$script2 = ".\process2.ps1"</p>
<p>cd $working_dir #Go into the working dir, for some reason</p>
<p>#<em>-WorkingDirectory </em>Switch did not work for me <img src='http://agilesoftwaretesting.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Start-Process $ps $script -RedirectStandardError &#8220;C:\TEMP\error.txt&#8221; -RedirectStandardOutput &#8220;c:\TEMP\out.txt&#8221;</p>
<p>Start-Process $ps $script2 -RedirectStandardError &#8220;C:\TEMP\error2.txt&#8221; -RedirectStandardOutput &#8220;c:\TEMP\out2.txt&#8221;</p>
<p>%></p></blockquote>
<p>Please notice that I’m redirecting the standard error and standard out into a file, this is the only way you will be able to debug, otherwise the Start-Process will swallow any error you get before you have a chance to actually see it.</p>
<p>Finally, put something inside the 2 scripts you will run, and give this a try J</p>
<blockquote><p><strong>Invoke-Command</strong> <em>-ScriptBlock</em> {</p>
<p><strong> Start-Sleep</strong> 15</p>
<p>&#8220;Job 1 Complete!&#8221; | <strong>Out-File</strong> &#8220;C:\temp\success.txt&#8221;</p>
<p>}</p></blockquote>
<p>This script is super simple, sleep for 15 seconds then output something into file. Both of my scripts did this at different intervals so you can see them as they finish up.</p>
]]></content:encoded>
			<wfw:commentRss>http://agilesoftwaretesting.com/?feed=rss2&amp;p=118</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium wait for AJAX (the right way!!!)</title>
		<link>http://agilesoftwaretesting.com/?p=111</link>
		<comments>http://agilesoftwaretesting.com/?p=111#comments</comments>
		<pubDate>Thu, 03 Dec 2009 21:11:06 +0000</pubDate>
		<dc:creator>Dima</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[selenium ajax jquery prototype dojo]]></category>

		<guid isPermaLink="false">http://agilesoftwaretesting.com/?p=111</guid>
		<description><![CDATA[How to make selenium wait for AJAX to finish, the right way]]></description>
			<content:encoded><![CDATA[<p>Ajax! Ajax! Ajax!!!!</p>
<p>You cannot go to a website without running into some form of Ajax. It’s great and all, but if you are trying to test a website with Selenium, this becomes an issue. Selenium will wait for the page to load, but is rather clueless when it comes to Ajax.</p>
<p>After spending several painful hours looking for a way to make a “wait_for_ajax” function, I found several solutions that do not work.</p>
<p><strong>1 &#8211; Put sleep in your test.</strong></p>
<p><em>Well obviously this is the simplest solution, but also the worst. We don’t know how long a request will take to load, what if the server is slow?</em></p>
<p><strong>2- Use “waitForElement” command built into selenium</strong></p>
<p><em>This is a better solution; we wait for a certain element, which is part of the Ajax response to appear before moving on. The problem with this solution is that we need to always know which element needs to load. This becomes a headache for us normal people with extra large web applications to support.</em></p>
<p><strong>SOLUTION!</strong></p>
<p>Here is the solution I stopped on. I won’t take credit for making it, but I’ll take some credit for compiling it all in one place. To be honest I have not seen it done yet, the only thing I’ve seen was for bits and pieces but not the whole problem.</p>
<p>To solve this problem, what we have to do is ask the browser to tell us how many active connections to the server are present. Then we sit and wait for that number to become 0. At this point we know that all Ajax requests went through and done, and we can move on in the test. (If you have a webapp that contains non-stop Ajax request to constantly update everything, you have my sympathy.)</p>
<p><strong>Step 1: Figure out which Javascript library your application uses</strong></p>
<p>This is important one, which had me stomped for a long time. Different libraries (Prototype, Dojo, jQuery) use different methods to retrieve the connection info.</p>
<p><strong>Step2: Create the wait_for_ajax method</strong></p>
<blockquote><p><em>def wait_for_ajax(timeout=5000)</em></p>
<p><em> js_condition = “”</em></p>
<p><em> $selenium.wait_for_condition(js_condition, timeout)</em></p>
<p><em>end</em></p></blockquote>
<p><em> </em></p>
<p>Let’s break this one down.</p>
<ul>
<li>We have a default value of 5000 milliseconds for this method, but user can up or down it as they need.</li>
<li>js_condition will be a string, which will contain a selenium call to the browser’s javascript. It will be a javascript conditional that will wait for active connections to be 0, and then return “true”</li>
<li>$selenium.wait_for_condition is the method that will sit and wait for the javascript query to return “true” before letting you move on.</li>
</ul>
<p><strong>Step 3: Getting the right JS query for your library.</strong></p>
<p>This part was the one, which took me the longest to figure out. But I’ll give you all the answers here. Different libraries use different functions to check incoming connection, so pick the right one for you.</p>
<p>jQuery: “jQuery.active”</p>
<p>Prototype: “Ajax.activeRequestCount”</p>
<p>Dojo: “dojo.io.XMLHTTPTransport.inFlight.length”</p>
<p><strong>Step 4: Put together the JS search string</strong></p>
<p>“selenium.browserbot.getCurrentWindow().” + library specific string + “ == 0”</p>
<p>Final string for jQuery will look like this</p>
<p><em>js_condition = “selenium.browserbot.getCurrentWindow().jQuery.active == 0”</em></p>
<p><strong>Step 5: Put the method all together and enjoy <img src='http://agilesoftwaretesting.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p>
<blockquote><p><em>def wait_for_ajax(timeout=5000)</em></p>
<p><em> js_condition = “selenium.browserbot.getCurrentWindow().jQuery.active == 0”</em></p>
<p><em> $selenium.wait_for_condition(js_condition, timeout)</em></p>
<p><em>end</em></p></blockquote>
<p><strong><br />
</strong></p>
<p>If I’m missing something, let me know. But spread the word, I know many of selenium users need this.</p>
]]></content:encoded>
			<wfw:commentRss>http://agilesoftwaretesting.com/?feed=rss2&amp;p=111</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.971 seconds -->
<!-- Cached page served by WP-Cache -->
