Feeds:
Posts
Comments

are you automating test of a product?

are you sure that the automation is really important or not?

be sure that manual test cost > automated test cost.

How??

easy… just calculate first

manual test cost = manual preparation cost + (N x manual execution cost)

automated test cost = automated test preparation + (N x automated execution cost)

… where N is the number of time test run.

We should use test automation only when it advances the mission of testing.

I needed to download directory from ftp server modify it and uploaded back to server using powershell. At fist i found that [System.Net.WebRequestMethods+Ftp]::UploadFile and [System.Net.WebRequestMethods+Ftp]::DownloadFile works fine and in real life when my zip file size is bigger it does not work.

I have not found any solution to make it working so I used alternative way to solve it. I have written two batch fildes upload.bat and downlaod.bat and calling these batch files from my PS Script to execute.

Actually if anyone use bat file he/she need not to call the bat file from PS Scripts but in my case after downloading zip file from ftp server I modified many things in the files using powershell and then upload it back to server.

Here are the batch files you can try if needed upload.bat and download.bat

to rename a file we use Rename-Item command in powershell the command is very simple

Rename-Item $source $dest -force

But what about changing a folder/directory name? I made mistake to write the same command in case of folder/directory rename and it does not work, shows exception file not found which proves that the command is searching for a file not ready to rename and folder/directory.

After googling for some minutes I found the solution and the command is

Rename-Item -path $destFolder -newName $folderNewName

Example: Rename-Item -path ‘C:\AshrafTest\MyFolder’ -newName ‘MyFolder_New’

By the way the folder should contain some data to be rename. Pretty simple but wasted time to search internet so sharing :-)

Recently I was trying to automate one step of my internet explorer actually my automation step was very simple I just needed to navigate an URL, read DOM of the URL, get text boxes and enter data in it. After entering data in text boxes I was suppose to click on login button.

Actually one of my 3rd party tool is depending on the login and was trying to automate the login and run the 3rd party tool so I need not to go to server everyday and do that.

It is easy to automate Internet Explorer by using a COM control named Microsoft Internet Controls (SHDocVw). To browse the DOM Microsoft.mshtml is used. I found a very helpful article with code in codeproject.com. here is the article : Automating Internet Explorer

By the way, I was facing problem to insert data in the text box  and click button. It worked fine in my local computer where VS is installed but for the computers where VS is not installed it shown exception to convert _Comobject to mshtml.HTMLInputElementClass . Download modified file.

My experiences says that we always suffer for asp.net application. because most of us use many tools for hosting and different provider gives different control panel. Overall it waste a lost of time to make the preparation of deployment in a shared hosting and at the time of hosting we face lots of problem too.

Today I watched a video in asp.net site which shown very clearly how we can easily deploy asp.net application in a shared hosting just using iis7 and visual studio. This is really a nice video. dot net developers who need to deploy products regularly in shared hosting should watch the video for faster deployment.

Watch the video here : Developing and Deploying In a Shared Hosting

Developing and Deploying In a Shared Hosting

Recently I have written a article which shows the power of WPF UI Automation. This library is really rich and make UI Automation easier.

Here is the article : Automate software using WPF UI Automation

I downloaded powerhsell from Microsoft website (http://support.microsoft.com/kb/968929) and installed it.

After successful installation I restarted computer and then open command prompt and write “Powershell” it shows me error “Add-PSSnapin : The Windows PowerShell snap-in ‘Pscx’ is not installed on this machine.”

To overcome that , download a 3rd party tool Powershell Community Extension from (http://pscx.codeplex.com/) and Install it. That will automatically override Profile.ps1 which was installed by powershell installation and will fix the problem.

Microsoft should add that in the installer.

As I am working with latest version of Powershell, when I tried to install latest version in XP I found that older version of powershell is available in software update for XP it is easy to find out and remove. But I really faced a big problem when I tried to install that in windows server 2003. I found all the software updates are named “Update of windows Server…” or “Security Update for windows server …” or “Hotfix for windows server 2003 …”. Its really hard to find out the right one and remove. After searching I found that I need to search for KB* to remove the older version.

Older version of powershell should be resembled any of the following

Hotfix for Windows Server 2003 (KB926139)
Hotfix for Windows Server 2003 (KB926140)
Hotfix for Windows Server 2003 (KB926141)

So find out the right one and remove it. Sometime it shows like that KB926139-v2, so don’t be confused. And after click on remove it will show you in the wizard that you are removing poweshell version 1.0 or anything else to be confirm you are really removing the right thing.

if you just need to install any software automatically using powershell you can just run the silent moder of the installer from powershell. The poweshell script to run exe or msi in silent mode is:

$command = “cmd.exe /c D:\MyInstaller.exe /s /v`”/qn”
$process = [WMICLASS]“\\PCName\ROOT\CIMV2:win32_process
$process.Create($command)

Remember your installer should have silent mode on in it.

I have a text file and in that file list of files and folder are available to copy from a local computer to a remote computer. This is very easy to do using powershell. Example is as follows

$remotePCName = “remotePC”
$remoteRoot = “\\$remotePCName\c$”
$DestFolder=”$remoteRoot\FileCopy\dest”
$SrcFolder=”C:\FileCopy\src”
$InputFile =”C:\FilesToExport.txt”

foreach ($FileLine in Get-Content $InputFile)
{
$src = $FileLine
$dest = $src.Replace($SrcFolder, $DestFolder)
if(!(test-path -path $dest))
{
if((get-item $src).PSIsContainer)
{
new-Item $dest -type Directory -force | out-Null
Copy-Item “$src\*” $dest -recurse
“Folder $dest Missing. Creating it!”
}
else
{
new-Item $dest -type File -force | out-Null
Copy-Item $src $dest -force
“File $dest Missing. Creating it!”
}
}
else
{
if((get-item $src).PSIsContainer)
{
Copy-Item “$src\*” $dest -recurse
“Copy file done for $src”
}
else
{
Copy-Item $src $dest -force
“Copy file done for $src”
}
}
}

a file syncronizer can be created by some code modification easily.

Older Posts »

Follow

Get every new post delivered to your Inbox.