Tag Archives: Selenium module

The hard fate of SePSX 0.4.8

The last month was a month of deep code restructuring. Experiments with the appropriate IoC (now, it’s Autofac), writing a number of fast tests, changing the chain of calls from cmdlet-code to cmdlet-command-code, all this stuff took time.

Things suddenly changed with yesterday’s Selenium 2.27. There were three of seven constructors broken in any driver server component (ChromeDriver, InternetExplorerDriver), and code has been changed significantly to avoid exceptions.

The last minute 2.27.1 fixes the issue, however, code of SePSX became more stressful to this type of issue. Selenium 2.27.1 is available as Beta 3 of 0.4.8.


Web automation: a small data-driven test with Selenium

Just to observe, how Selenium cmdlets can be working ‘in parallel’:

ipmo [path]\SePSX.dll

$searchData = @("cheese", "juice", "wine");


[int]$counter = 0;
$drivers = Start-SeChrome -Count 3;
$drivers | Enter-SeURL "http://google.com" | %{ $null = $_ | Get-SeWebElement -Name q | Set-SeWebElementKeys $searchData[$counter] | Submit-SeWebElement; $counter++; }

$drivers | Read-SeWEbDriverUrl;

Test Case Management: generating test results on the fly

The truth is that almost nobody writes test cases these days by hands. Okay, for big and serious, and requiring mind efforts things like scenarios, testers write. PowerShell frameworks are all about automation and demand as little manual work as possible. Like other GUI and Web testing tools, PowerShell frameworks generate test results by watching the code execution. Let’s go to the samples:

ipmo [path]\SePSX.dll
[SePSX.Preferences]::EveryCmdletAsTestResult = $true;
Start-SeFirefox | Enter-SeURL "http://google.com" | Get-SeWebElement -Name q | Set-SeWebElementKeys Cheese | Submit-SeWebElement;

What did we expect from this code? We set the EveryCmdletAsTestResult setting on, started an instance of Firefox, navigated to Google and submitted a query. As we saw no errors, we want to get our passed test results. How to do that?

[TMX.TestData]::CurrentTestScenario.TestResults | FL Name,Status

The output is as follows:
Name : Start-SeFirefox
Status : PASSED

Name : Enter-SeURL “http://google.com”
Status : PASSED

Name : Get-SeWebElement -Name q
Status : PASSED

Name : Set-SeWebElementKeys Cheese
Status : PASSED

Name : Submit-SeWebElement;
Status : PASSED

Name :
Every cmdlet reported itself as Passed, and five results display this. The sixth result is a pre-generated test result that will be used in the immediately next cmdlet call.

This is too ideal, now we change our code to obtain real-life results. We are seeking for one of Google 2.0 controls, namely ‘q2’ (Marissa Mayer’s gone, hasn’t she?).

ipmo [path]\SePSX.dll
[SePSX.Preferences]::EveryCmdletAsTestResult = $true;
Start-SeFirefox | Enter-SeURL "http://google.com" | Get-SeWebElement -Name q2 | Set-SeWebElementKeys Cheese | Submit-SeWebElement;

The code failed (controls have not been renamed yet), where are our results?

[TMX.TestData]::CurrentTestScenario.TestResults | FL Name,Status

The output is below:
Name : Start-SeFirefox
Status : PASSED

Name : Enter-SeURL “http://google.com”
Status : PASSED

Name : Get-SeWebElement -Name q2
Status : FAILED

Name : Get-SeWebElement -Name q2
Status : FAILED

Name :

The third and the fourth results have different exceptions in their Descriptions, though it’s a place where module’s code review needed…

Now, let’s see how time was consumed:

[TMX.TestData]::CurrentTestScenario.TestResults | FL Name,Status,TimeSpent

As can be seen, there is a default 500 milliseconds’ delay after starting the browser, 2 seconds were spent on navigation to the google page, and 5 seconds (the full time of [SePSX.Preferences]::Timeout) were spent on attempts to get the control of our interest.

In practice, testers are often interested in Failed results, much more often that in the list of Passed. 🙂 How to obtain such a list? First of all, we need to import the TMX module. Selenium and UIAutomation modules use TMX indirectly, as a library, but the advanced functionality is available as cmdlets:

ipmo [path]\TMX.dll;
Search-TMXTestResult -FilterFailed | FL Name,LineNumber,Code,Details

If the time of every test result is stored, what benefits do we have? Consider using the following query:

Search-TMXTestResult -OrderByTimeSpent -Descending -FilterFailed | FL Name,TimeSpent,Code

This lists Failed test results and time consumed in the descending mode (for what kind of user the contemporary versions of MS Excel have been written? Maybe, I’m wrong here? Okay, I’ll rewrite). This command lists Failed test results from bigger time spent to smaller.

Web automation: SePSX 0.4.0


To the version 0.4.0, though it’s still alpha, the following features, best known as belonged to the UIAutomation framework, have been added:

  • On error delay
  • On success delay
  • Automated test result generation

On error and on success scriptblocks (actions), and logging are not completely done yet.

Among other features that have been implemented the last week, the following list:

  • Smart wait for an element ([SePSX.Preferences]::Timeout as you have already understood, by the analogy with UIAutomation)
  • The square over the element a cmdlet returned has been tied to the right position

PowerShell and Selenium go ahead of paid competitors

An interesting query can be seen at the indeed.com portal:

The demand for test automation engineers with QTP experience grows, whereas primordial WinRunner goes towards zero in popularity. TestComplete and Ranorex have never been more than outsiders, but there is also a surprise about TestManager.

I think that all non-enterprise test tools are simply less known to serious enterprise customers. The second cause may be here that an average HR manager does know TFS but not MTM.
Anyway, the strong marketing machine of Microsoft and the tight integration with Studio and TFS should help in MTM’s advancement.

Here, one hope takes place. As, first and foremost, a big ally of open source testing solutions, I’d like to predict that in several areas, namely Windows UI Automation, Web Automation, maybe Metro UI automation and, definitely, automation of labs of any kind, there will be a breakthrough of open source testing instruments.

Let’s see what we have now. Regarding Windows desktop automation, there are a lot of frameworks with the ability to test Win32, Windows Forms, WPF, Silverlight applications. The only thing to perform a step to the mass-market is the need in a covering application that would embrace frameworks to an out-of-the-box solution. I mean a typical ‘download, set up and run’ and ‘click’n’play’ solution.

There are problems with third-party controls though. Nonetheless, we can now create an end-to-end testing solution on bare .NET or PowerShell (even me, just a tester, created one of such kind).

In the world of web automation, there is the unbeatable leader now. Supported by almost all browser vendors, Selenium is getting a standard tool for web-testing (and even going to become an official standard).

Well, the state of affairs seems to be very good, even though paid competitors struggle with FOSS. I’d like to think that one or more vendors of paid testing software will drop a free solution to the public within next two years. I don’t know, of course, whether it will be MTM Express, TestIncomplete or Ranorex UltraLite, but I believe that outsiders will act in this way too.

Happy testing with free solutions!

%d bloggers like this: