Saturday 26 February 2011

QC DATA PULLER using C#

Using this application user can generate report of test case execution from QC(Quality center) in to HTML web page with fancy pie chart and tabular format using C# and OTA API expose from QC(Quality Center).
i have pulished an Articles on Code project for generating report for test cases executed from QC. the report would be in HTML web page format with pie chart and tabullar format.

for more details you visit below link for that:
QC Data Puller on Code Project.
Please go through the link and provide your valuabe comments and suggestion!!
Thank you!!
~jawed

Monday 21 February 2011

Post Comments web page in ASP.Net using C#

Recently I have developed a web application automation application in which I have added a functionality for the user to post their comments, experience and questions for the admin.
Thought to share this approach with all of you.
So here is my approach what I have done.
1. An aspx page with name URComments.aspx.
2. we will use XML file to store all the comments posted by the users.
3. Used GridView to show all the comments posted by the users.
4. On page load and/or on post button click we will call a funtion to read all the comments
posted till now by the user and show that in to GridView.
5. Below controls we will on design view of URComments.aspx.
a. Text box to get the Emailid from the user.
b. Text box for the user to entered Comments and/or suggestion.
c. Button to submit comments.
d. GridView to show all the comments posted till that time.
The web page would look something like this:

Fig 1. Web Page with Post Comments Feature

6. The XML file format would be something as below. This XML file we will use to store all the comments provided by the user. B d way you can customize this as per your requirement.


fig 2. XMl File to store Comments posted by User
Page Load :
public static string xmlPath =ConfigurationSettings.AppSettings["xmlFilePath"].ToString();
//on page load redirect the user to the specific url and then show all the comments
//posted //till //now
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
showThePostOnWebPage();
}

}

Showing Post in Web Page:
//Display the Post on webPage
public bool showThePostOnWebPage()
{
bool result = false;
try
{
DataSet dsForWebPage = readXMFile();
GridViewPost.DataSource = dsForWebPage.Tables[0];
GridViewPost.DataBind();
result = true;
}
catch (Exception ex)
{

}
return result ;
}


Reading the XML file for the comments posted till now:
//Read the xml File
public DataSet readXMFile()
{
DataSet ds = new DataSet();
System.IO.FileStream fsReadXml = null;
try
{
//Read an XML file to generate serial number
fsReadXml = new System.IO.FileStream(xmlPath, System.IO.FileMode.Open);
//Declare a dataset to hold all the XML value
//Read the value from XML reader to the dataset
ds.ReadXml(fsReadXml);
}
catch (Exception ex)
{
ds = null;
}
finally
{
fsReadXml.Close();
}
return ds;
}

On Button click (when user tried to submit the post):
protected void ButtonPost_Click(object sender, EventArgs e)
{
FileStream fsxml = null;
FileStream fs = null;
try
{
//check that the comments textbox is not empty
if (TextBoxComments.Text != null && TextBoxComments.Text != string.Empty )
{
//Read an xml file to get all the post commented till now
DataSet dsSet = readXMFile();
if (dsSet != null)
{
//make sure that table exist
int totalRowCount = dsSet.Tables[0].Rows.Count;
string strSerialNumber = null;
string getTheNumber = null;
if (totalRowCount <= 0) { getTheNumber = "1"; } else
{
//get the number
strSerialNumber = dsSet.Tables[0].Rows[totalRowCount - 1][4].ToString();
getTheNumber = strSerialNumber.Remove(0, 3);
}

Int32 currentSerialNumber = Convert.ToInt32(getTheNumber);
Int32 nextSerilaNumber = currentSerialNumber + 1;
string strSerialNumberToadd = "CFG" + nextSerilaNumber.ToString();
fs = new FileStream(xmlPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(fs);
// New XML Element Created
XmlElement newcatalogentry = xmldoc.CreateElement("CFGPost");
// New Attribute Created
XmlAttribute newcatalogattr = xmldoc.CreateAttribute("ID");
// Value given for the new attribute
newcatalogattr.Value = strSerialNumberToadd;
// Attach the attribute to the XML element
newcatalogentry.SetAttributeNode(newcatalogattr);
// First Element - Comments
XmlElement firstelement = xmldoc.CreateElement("Comments");
// Value given for the first element
firstelement.InnerText = TextBoxComments.Text.ToString();
// Append the newly created element as a child element
newcatalogentry.AppendChild(firstelement);
// Second Element - Date
XmlElement secondelement = xmldoc.CreateElement("Date");
// Value given for the second element
secondelement.InnerText = DateTime.Now.ToString();
// Append the newly created element as a child element
newcatalogentry.AppendChild(secondelement);
// Third Element - EmailID
XmlElement thridelement = xmldoc.CreateElement("EmailId");
// Value given for the third element
thridelement.InnerText = TextBoxEmailId.Text;
// Append the newly created element as a child element
newcatalogentry.AppendChild(thridelement);
// Fourth Element - UserName
XmlElement fourthelement = xmldoc.CreateElement("UserName");
// Value given for the fourth element
fourthelement.InnerText = hostName.ToString();
// Append the newly created element as a child element
newcatalogentry.AppendChild(fourthelement);
// New XML element inserted into the document
xmldoc.DocumentElement.InsertAfter(newcatalogentry,xmldoc.DocumentElement.LastChild);
fs.Close();
// An instance of FileStream class created
// The first parameter is the path to the XML file
fsxml = new FileStream(xmlPath, FileMode.Truncate,
FileAccess.Write,
FileShare.ReadWrite);
// XML Document Saved
xmldoc.Save(fsxml);
fsxml.Close();
//Clean the text box area
TextBoxEmailId.Text = string.Empty;
TextBoxComments.Text = string.Empty;
bool flag = showThePostOnWebPage();
RegisterClientScriptBlock("js", "
");
}
else
{
//show the message to the user that currently we are facing some issue
RegisterClientScriptBlock("js", "
"
);
}
}
//if it is empty then show the message to user
else
{
RegisterClientScriptBlock("js", "
"
);

}
}
catch (Exception ex)
{

}
}

Method whenever user clicked on Pagination of Grid View
//fire this even whenever user clicked on pagination at gridView
protected void GridViewPost_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
GridViewPost.PageIndex = e.NewPageIndex;
showThePostOnWebPage();

}
catch (Exception ex)
{

}
}

Now you are ready with the Post Comments project.
You can integrate this with your web application to provide the user an option to share their suggestion/comments and issues with others.
Hope you would get benefited form this.

Feel free to provide your comments.
*************************
Thank You,
Md. Jawed

Wednesday 16 February 2011

Debugging, Tracing and Instrumentation in .NET and ASP.NET (14 FAQ) by Shivprasad koirala

A nicely explained article about Debugging, Tracing and Instrumentation in .Net.
This article is posted on Code Project by Shivprasad koirala.
He has explained everything in such a nice way with nice images and videos that you will understand all the pin point of Debugging, Tracing and Instrumentation in .Net.
Let me put some contents from his post:
What is Instrumentation?
Debugging application is not just about pressing F 10 or F 11 and watching “add watch windows” using visual studio IDE. Debugging becomes pretty complex on production environments where the project is deployed in a release mode and you need to figure out till what point the code ran and when did it crash. The worst part is you are enjoying your sleep at home and suddenly someone calls up and says, “Hey! the application crashed in production”.If your application is well planned with proper instrumentation you can just say the person to view the event viewer or a log file for further details and you can give the solution on the phone itself.So defining instrumentation in short, it’s the ability of the application to monitor execution path at critical points to do debugging and measure performance.
What is debugging and tracing?
We would like to enable application instrumentation in two situations while you are doing development and while your application is in production. When you monitor application execution and performance in development stage is termed as “Debugging” and when you do in deployed environment it’s termed as ‘Tracing’.


Thanks to Shivprasad koirala for posting such a useful and knowledgeable articles.
Hats off to you!!!
~jawed

Tuesday 15 February 2011

WatiN 2.0 Final Released: Ready to Download


Finally Watin 2.0 released to download.
Below is the Email from Jeroen van Menen.
All,
Last week I have release WatiN 2.0 Final (2.0.50.1179). You can download the zip file from Sourceforge:
http://sourceforge.net/projects/watin/files/WatiN%202.x/2.0%20Final/WatiN-2.0.50.1179.zip/download
or install it using NuGet (need to have the Package Manager console for Visual Studio 2010 installed, get it at nuget.org). Installing is as simple as:
PM> Install-Package WatiN
The release notes can be found on the new website http://watin.org/ (which is still in flux but getting there)
http://watin.org/documentation/release-2-0-50-11579/
Enjoy Testing with WatiN!

Jeroen

~JAWED

Thursday 3 February 2011

Test Automation FX - UI Testing in Visual Studio

Few days back there was some requirement in my project where we have to automate windows application/desktop application developed in C#.Net. I thought to develop an automation framework for the same. But before starting of this we thought for doing some goggle might be some tool would be available to perform my task.

After searching I came across TAFX(Test Automation FX). This was a nice tool which will give you the freedom of language, recording and nice flexibility to customize the generated code after recording.


Let me put some point which I have noted down from web:
Test Automation FX (TAFX for short) enables developers and testers to record and manage user interface tests from inside Visual Studio with 100% .NET code.
You go through this official web site of TAFX:
http://www.testautomationfx.com/
Go through below link to get screen shot of Automation of Calculator using TAFX:
http://www.testautomationfx.com/index.php/screenshots

Shortly, I m planning to give a try to this tool. Will forward my finding and experience in next blog soon.
this is not an open source tool :(
Please comments with your finding also about this tool.
~jawed