Thursday, April 30, 2009

Ways to improve user experience in any website


As of now, I can think about below things to improve user friendliness or user experience.

  • Put the cursor (i-e give focus) in the appropriate HTML control/element immediately after loading the webpage. If possible provide appropriate/standard shortcut keys. When doing javascript validation also, give focus to the appropriate control/element.

  • Keep the menu/navigation very clearly to avoid any ambiguity/confusion. Especially any "Back" button should load appropriate previous page with appropriate contents.

  • Any scroll bar should be shown dynamically to improve the user friendliness.

  • All the pages should have link to the Home page

  • Clicking on any link should load the page in new window or in same window based on the context(e.g Calendar window for date selection should be opened in new window). If you are choosing to open it in new window, then don't forget to provide close button in the new window.


  • Always show appropriate confirmation once after completing operations such as save, update and delete. And also, get confirmation from user before deleting any data from database by showing alert Dialog.

  • Provide appropriate Page Title and Page Heading to help the user to understand his navigation path.


  • If possible use cookies to improve user experience by storing frequently used details/preferences in user's machine


  • We can provide WYSIWYG editor such as FCKeditor instead of textarea to enable the user to do desired formatting. Please remember to include textarea also if the editor (iframe) is not supported by any browser.



More Articles...

Read more ...

Steps for using FCK editor


FCK editor is a php code used for providing WYSIWYG editor facility in website developed using php.


a . Copy and paste the FCK editor folder (which holds the files related to the FCK editor) into your project folder.
b. Use the following code for including FCK editor.

include ("../FCKeditor/fckeditor.php");
$oFCKeditor = new FCKeditor("message") ;
$oFCKeditor->BasePath = '../FCKeditor/' ;
$oFCKeditor->Value ="";
$oFCKeditor->Create() ;

Here message is the name of the HTML element, you can give your own name as per your need. This name can be used as any other HTML element for getting the value from $_POST.

It seems FCKeditor is not working in Chrome.

More Articles...

Read more ...

For using javascript Calendar in web page


1. To use calendar in our page, we should include one JS file in our project on the same path of our page.
2. Paste the following line in <head>

<SCRIPT LANGUAGE="JavaScript" SRC="CalendarPopup.js"></SCRIPT>

<SCRIPT LANGUAGE="JavaScript" ID="js1">
var cal1 = new CalendarPopup();
</SCRIPT>

3. Paste the following two lines where you want to show calendar and inside <body>

<INPUT TYPE="text" NAME="date1" VALUE="">
<A HREF="#" onClick="cal1.select(document.forms['frmCal'].date1,'anchor1','yyyy-MM-dd'); return false;" TITLE="); return false;" NAME="anchor1" ID="anchor1">select</A>

4. Here I use the name of the form (frmCal). Instead of that you can use the form number of that form. Suppose that is the first form then the form number should be zero.

Remember to give proper unique name for anchor tags and for text boxes to use multiple calendars in same form.

More Articles...

Read more ...

Focusing HTML element immediately after loading the web page


Focusing (i-e putting cursor) appropriate control/HTML element in a webpage will enhance the user experience.

It should be done once after loading the page.

We can use the below javascript code for doing this on onload event of window.

This code should be placed inside the head tag.
<script type="text/javascript">
window.onload = function givefocus(){document.forms[0].elements[0].focus()}
</script>

Another way is we can do it on the onLoad event of body tag as below,

<body onLoad="document.frmname.name.focus();">
<form name="frmname" id="frmname" action="" method="post">
<input type="text" name="name">
</form>
</body>

More Articles...

Read more ...

How to avoid multiple lines in <td> tag?


In some situation (viewing in different browsers) the single <td> tag displays content in two lines. If you want to display sentence in single line always in all browsers then use <td> attributes ‘nowrap’

For example,you may want username/userid/Name to be displayed in single line, but due to some reason or different browser it will display in two lines like below,
username/userid
/Name .

So to avoid this issue use ‘nowrap’ as below.

<td width="48%" align="right" valign="bottom" nowrap> Username/userid/Name<td>

More Articles...

Read more ...

Getting current Page Name in PHP


$_SERVER[‘PHP_SELF’] will be used for getting current page name in php.

It will be necessary for us to use this $_SERVER[‘PHP_SELF’] for action attribute of form element if you want to post the form into the same page. If you use the filename instead of this variable then we may face difficulty when we change the file name.


If the page is located in sub-folder, then this variable will return the page name along with sub-folder name also (e.g qualtypoint/index.php)

If you want to get only the filename (e.g index.php) then you should use basename() as below.
basename($_SERVER[‘PHP_SELF’])

More Articles...

Read more ...

PHP function to get the ID generated from the previous INSERT operation in mysql


It is necessary to get the ID (auto increment field) of a row inserted into a mysql table if the table is having any parent-child relationship with one or more child tables.

For example, assume that we are entering questions and multiple answers. The questions will be inserted into question table. The id in question table will be used in answer table for relating the question with answers.

So we need to get the id from questions table once after inserting the question.

We can use many different approaches to achieve this.

1. We can have a php variable assigned with current time, this variable value can be stored in question table as hash.
Once after completing the question insertion we can select the id corresponding to this hash from the question table. This approach needs one additional column in the table for storing the hash.

2. We can select the id as "select max(id) from question". This approach will work only when the id is getting incremented continuously.

3.The best way is we can use the php function Mysql_insert_id() to retrieve the ID generated for an AUTO_INCREMENT column by the previous/last INSERT query.

Related Articles...
More Articles...

Read more ...

Javascript example for selectively displaying particular div based on drop-down selection


display property of style for any div tag can be set as "block" to display the div content, or it can be set as "none" to hide the contents of div tag.

Here I will explain how to use this display property to hide or show a div tag based on the value selected in a drop down list.

Consider below HTML form having two drop-down lists. One (appointment_for) is having two options myself and others.

The another drop-down list (appointment_for_others[]) is placed inside a div tag which is hidden by default using style "display:none".


<form name="frmadd">
<table>
<tr><td>
<select name="appointment_for" id="appointment_for" onChange="showHideOthers();">

<option value="myself" selected>Myself</option>
<option value="others">Somebody Else</option>
</select>
</td>
<td>
<div id="others" style="display:none" >
<select name="appointment_for_others[]" id="appointment_for_others" multiple size="3">
<option value="" selected>Select</option>
<option value="Name1" >Name1</option>
<option value="Name2" >Name2</option>
</select>
</div>
</td>
</tr></table>

</form>


Here our intention is to show the second drop-down list on selecting other in the first drop-down list.

To achieve this we can call a javascript function during onChange event of first drop-down list to unhide the second drop-down list on selecting other in the first one.

Find the below sample javascript function used for this purpose.

<script language="javascript">
function showHideOthers()
{
if (document.frmadd.appointment_for.selectedIndex==0) //Hide others drop-down list if myself is selected
{
document.getElementById("others").style.display='none';
}
else //show drop-down list of others
{
document.getElementById("others").style.display='block';
}
}
</script>




You can visually see it here. If you select 'Others' in the below drop-down list you can see another drop-down list here.












More Articles...

Read more ...

Javascript validation for radio button in HTML form


HTML is having INPUT tag with radio as type to display radio button in the HTML form.

Multiple input tags should be given same name to make it one group.

Consider below code which will allow the user to select any one of 3 topics.

<form>
<input type="radio" name="topicname"/>topic1

<input type="radio" name="topicname"/>topic2

<input type="radio" name="topicname"/>topic3
</form>


If you want to keep this radio value selection as mandatory (i-e topic should be selected before submitting the form), you can use below javascript function.

function validation(myform)
{
var myOption = -1;
for (i=myform.topicname.length-1; i > -1; i--)
{
if (myform.topicname[i].checked)
{
myOption = i;
i = -1;
}
}
if (myOption == -1)
{
alert("You must select a Topic");
return false;
}
}


More Articles...

Read more ...

Detecting browser type using javascript


Many different browsers (e.g FireFox, IE,chrome,opera,safari)are available for displaying webpages. Each and every browser will have their own way of rendering content of webpage, and script (e.g javascript) execution also will vary based on the script engine implemented with them.

So it is very difficult to design a webpage which looks/works good in all browsers.
But anyway we should make the website to look good in all browser to reach maximum users.

So even we can write separate code for each browser and we can call it is based on the browser type of the user. And therefore a function for finding the browser type of the user is necessary.

Find below a sample javascript function for finding browser type.

function getbrowsertype()
{
var BrowserAgent;
BrowserAgent=navigator.userAgent;
var BrowserType="";
try
{
if ((BrowserAgent.indexOf("Firefox")!=-1))
{
BrowserType="firefox";
}
else
{
BrowserType="others";
}
}
catch(Exception)
{
BrowserType="others";
}
return BrowserType;




The above sample code will just detect whether the browser is firefox or others.

You can enhance it to include all other browsers also.
The try/catch is necessary here as the browser finding code supported by one browser may not be supported by another.

More Articles...

Read more ...

Displaying Random records from MySQL database table


Sometimes we may need to display some value selected from database table which is having many records. In this situation we can select them randomly to improve user experience. It applies to displaying random advertisements, testimonials, quotes,images,background colors and news.

php is having a function rand() for getting random number within a range. Syntax is shown below.

int rand ( int $min , int $max )

Sample code is shown below.

$sqlbanner="select * from table_name
$recbanner=mysql_query($sqlbanner);
$rows=mysql_num_rows($recbanner);
$rand=rand(0,$rows-1);
$page_text=mysql_result($recbanner,$rand,'page_text');


We can use RAND() function of MySQL also to achieve this.

For example below code will select 10 random rows from the mysql table.

SELECT * FROM <table name> where <condition> ORDER BY RAND() LIMIT 10
More Articles...

Read more ...

Handling Date and Time in PHP/MySQL


Date and time can be inserted into mysql table in specific format only. But php will support different types of date and time formats.

So, we should convert the date and time from php into specific format before inserting the value into mysql table.

We can use the date() and strtotime() functions of the php to do it.

MySQL table will store and datetime correctly only when it is formatted as Y-m-d H:i:s.

(i-e) 4 digit year-2 digit month - 2 digit day blankspace 24hours hour:minute:seconds.

Refer the below sample code used for inserting datetime into mysql table.

- Assume that Date and time values are stored in two different variables($dateinput,$timeinput) in php.
- First we need to concatenate both date and time to get single string.
- Then use strtotime() to convert this single string into time data which can be formatted using date() function to get required format.


<html>
<body>
<?php
include "config.php";//connected with database

$dateinput="02/14/2009";
$timeinput="10:30 pm";
$dt1=date( "Y-m-d H:i:s",strtotime($dateinput. " ".$timeinput));

$sql="insert into test (sttime) values ('$dt1')";
if (mysql_query($sql))
{
echo "successfully inserted";
}
else
{
echo mysql_error();
}

?>
</body>
</html>




Similary strtotime() can be used to get previous and next days/weeks/months/years also.

For example below code will get the previous 1 week.

$fromDate=date("Y-m-d",strtotime($displayDate."-1 week"));

More Articles...

Read more ...

Email syntax validation using javascript


We should validate the syntax of email entered in the form in the client side itself to save unnecessary server process to validate the email.

It can be done using javascript.
Consider below form.
onSubmit event of Form is calling a javascript function ValidateForm


<form name="frmSample" method="post" action="" onSubmit="return ValidateForm();">
<p>Enter an Email Address :
<input type="text" name="txtEmail">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>



The javascript function ValidateForm is calling another function emailcheck to validate syntax of the email id.


<script language = "Javascript">

function emailcheck(str) {

var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){

return false //if @ symbol is not there
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

return false //if @ symbol available at starting or ending of email.
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

return false //if "." is not available, or available at beginning or end of email.
}

if (str.indexOf(at,(lat+1))!=-1){

return false //if more one @ symbol available in email
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

return false //if no letter is available between @ and "."
}

if (str.indexOf(dot,(lat+2))==-1){

return false
}

if (str.indexOf(" ")!=-1){

return false //if blank space available in email.
}

return true
}

function ValidateForm(){
var emailID=document.frmSample.txtEmail

if ((emailID.value==null)||(emailID.value=="")){
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (emailcheck(emailID.value)==false){
emailID.value=""
emailID.focus()
return false
}
return true
}
</script>

More Articles...

Read more ...

Removing text from Textbox on giving Focus


Webpage should be designed such that the elements/controls occupy less space in any webpage for improving user-friendliness, especially in Home page of any website.

This can be achieved in many different ways. One way is instead of displaying the Labels of Textbox separately, we can display them within the Textbox itself. On focusing the textbox, this label text can be removed.

For example consider the below login page.


The Username and Password labels are getting displayed in respective Textbox before giving focus to them.
On focusing the Textbox, the Label Text will be removed from the textbox to allow the user to enter required text.

Find below the sample code to achieve this.

    
<table>
<tr>
<td><input type="text" name="username" value="Username" onBlur="if(this.value=='') this.value='Username';" onFocus="if(this.value=='Username') this.value='';" ></td>
</tr>
<tr>

<td><input type="password" name="password" value="Password" onBlur="if(this.value=='') this.value='Password';" onFocus="if(this.value=='Password') this.value='';"></td>
</tr>


</table>


More Articles...

Read more ...

Wednesday, April 29, 2009

Displaying vertical scroll bar dynamically in HTML elements


Vertical scroll bar in HTML controls/elements/tags such as TEXTAREA and SELECT will be useful if the element has more content/items.

But always showing Vertical scroll bar will be occupying some space in the page unnecessarily.

So the best way is, showing the Vertical scroll bar dynamically only when the content exceeds a limit.

It can be achieved by specifying "overflow" as auto in the style.

(e.g)

<textarea style="overflow:auto"> some content</textarea>

Similarly we can specify overflow as hidden if we don't want to show the scrollbar.

It is working fine for Textarea in both IE and FireFox.

But it is not working for Select in FireFox.

Select tag in FireFox is showing scroll bar even when we specify overflow as hidden.
And also, we have noticed that it happens only when the number of items/options in the Select exceeds 20.

By searching the internet we came to know that there is no way to make it work properly other than some ineffective ways such as hiding the scroll bar using some div tags.
More Articles...

Read more ...

Doing case insensitive search in C#.Net


It seems C# is doing case sensitive search by default.

Consider below two variables.

string name="QualityPoint"
string searchword="quality"

name.IndexOf(searchword) will return -1 as quality is different from Quality when doing case sensitive search.

If you want to make it a case insensitive search you should use as below
name.IndexOf(searchword,System.StringComparison.CurrentCultureIgnoreCase)
More Articles...

Read more ...

Tuesday, April 28, 2009

Converting Letter Case in php/MySql


LCASE can be used in MySQL query to get the output in all lower case letters.

For example below query will display the username in lowercase.

SELECT lcase(username) FROM `users`

Similarly UCASE can be used for getting the output in all upper case letters.

Alternatively, we can use php functions strtolower() and strtoupper() for achieving the samething.
More Articles...

Read more ...

Doing page redirection in PHP


Page redirection can be done in PHP file using header() which is used to send a raw HTTP header.

(i-e) header("Location:newpage.php"); will load the newpage.php.

Note that header() must be used before sending any output either by HTML tags, blank lines or from PHP. Otherwise error message "header already sent" will be shown.

In this situation, we can use javascript for doing page redirection as below

window.location="newpage.php";

Some users might have disabled javascript in this browser for security reasons.
In this case, we can show a link for them go to the desired page.

Find below function written in PHP for doing page redirection by handling all the scenarios.

function redirect()
{

if (!headers_sent()) header("Location:newpage.php");
else echo "<script>window.location=\"newpage.php\";</script>
<noscript>Automatic redirection didn't work.<br />
<a href=\"newpage.php\">Click here to go to newpage.</a></noscript>";
}



If you want to use the variables of current page in the new page also, then include the new page (e.g include "newpage.php";)instead of doing redirection.

More Articles...

Read more ...

Workaround for Back button issue in FCKeditor.


FCKeditor is very useful tool for allowing the user to enter the formatted text in a webpage without having knowledge in HTML.

If we click Back button in the browser once after entering content using FCKeditor, the browser won't go to actual previous page, instead it will remain in samepage with the empty content. We noticed that clicking Back button two times displays correct previous page.

To avoid this issue, we have used below workaround.

- We provided a separate back button in the webpage. In the onclick event of this button, we called a javascript method to simulate clicking of browser back button two times.

- Find below the sample code.

<button onclick="javascript:history.go(-2);">Back</button>

And also, we have noticed that sometimes (e.g. after saving the content) we need to click browser back button 4 times to go the previous page.

To handle this scenario, we can enhance the above sample code by replacing -2 with a PHP variable whose value should be set either -2 or -4.

for example,

- pass a querystring parameter confim=updated once after finishing the save operation.

- use below code to assign value for a php variable based on the flow.

if (isset($_GET['confirm']))
{
$backcount=-4;
}
else
{
$backcount=-2;
}


- Now this php variable can be used in our previous sample code.

<button onclick="javascript:history.go(<?php echo $backcount;?>);"> Back</button>

updates on May 08:

It seems we need to use "return false" as below to avoid issue in some browsers (IE 7 and FireFox).

<button onclick="javascript:history.go(<?php echo $backcount;?>);return false;" > Back</button>

More Articles...

Read more ...

Sunday, April 26, 2009

Quick Introduction to RSS feed/Syndication


We can see an Icon like this in many websites.

This post will be useful for the readers who are not familiar with this icon.

Actually this icon represents the RSS feed of the website.

So, what is RSS feed?

RSS standards for "Really Simple Syndication" or "Rich Site Summary" or "RDF Site Summary".

The RSS feed is much useful for getting latest updates in a website/blog without navigating to that website and without giving our email id to that website. So we can easily get latest contents (e.g news) from websites without losing our privacy while saving our time by not needing to visit each site individually.

Note that we can use RSS feed only when the site provides support for this feed. i-e it should generate/provide the feed in specified format (XML format).

Publishing this XML file as the feed is known as Syndication.

There are many different ways are there to do syndication. In one of our projects we used PHP code for generating the xml file. It can be done very easily by gathering all the required from database, and create string by following standard RSS specifications.

The created string should be written into a file with extension .xml.


In another project
we created Desktop application for creating customized RSS feed as per our clients requirement.

As I mentioned previously, the content of the xml file should follow some standard RSS specifications.

Each RSS file should have some required channel elements such as title, link, description and can have some Optional channel elements such as language, pubDate,lastBuildDate, category, image.

A Channel element can have multiple item elements which will have elements such as title, link, guid and pubDate for the item.

W3C is providing feed validation service for verifying whether our feed file follows the RSS specifications correctly.

Till now we have seen how to generate/publish/syndicate the RSS feed.

So, now the RSS feed will be available once after the syndication. The next question will be how to use this Feed.

There are many readers (desktop- based and web-based) available for displaying this published RSS feed. These readers are called as RSS aggregators.

Now it is clear that RSS is nothing but a way of receiving recently updated contents from many websites to our aggregators( i-e our desktop or our website) simply by subscribing to the RSS feed.

For example, if you want to read latest posts (recently updated post) of our blog even without coming to our blog you can easily do it just by subscribing to the RSS feed of this blog.

For subscribing to the feed, just click the RSS icon located at sidebar under "Subscribe To QualityPoint"
. There you can see a list of aggregators. You can just select any one of them.

Below screenshots will explain about subscribing to a web-based aggregator (Add to Google)

Below screen will appear after clicking "Add to Google" link. We may need to enter username/password for google account it you are not already logged in.
Note that this email/password will not stored in the blog/website. Just you are logging into your google account.



On selecting "Add to Google" will show below screen.



Clicking on "Add to Google Reader" will show below screen. Here you can see the the latest updates from our blog.



Now you can read all our new articles from your Google account itself even without giving your email id to our blog.

More Articles...

Read more ...

How to detect Plagiarism?


Since Internet is accessible for every people, someone can copy the content from our website and can put it in their site and claim it saying that it is their content. This issue is called as "Plagiarism".

Note that it is not exactly same as copyright infringement.

Copyright infringement is violation of using copyright holder's content without his consent.

But Plagiarism is concerned with reputation of author which can be affected if his content already available in somewhere.

Say for example, you are publishing some content. And, the same content is already available in another website. So, the reader of your site who already visited the other site will be thinking that you copied the content from other site which ultimately reduce your reputation.

Normally, it will happen if you are outsourcing your writing work. Assume that you are asking some employees/contractors to write articles. If they are giving articles just by copying it from some sites, your reputation will be spoiled.

So it is very important to prevent Plagiarism to save your reputation or good name.
We can detect the duplicate work using service provided by www.copyscape.com. Just entering url of any webpage in this website will return list of already existing webpages having same/similar content.

Read this previous article which provides javascript code to prevent copying your webpage content.
More Articles...

Read more ...

QTP Learning Steps for Beginners


In previous post, I explained basic details of QTP.

In this post, I will explain how to start learning QTP and then explain how to proceed with your learning.

  • Begin with understanding the importance of software testing. You should learn software testing Concepts and you should have clear understanding of functional and regression testing. You need to be bit familiar with Manual testing such as writing test cases, executing test cases and reporting the issues.


  • You should understand the need and importance of software test automation. before learning QTP.



  • Download some good QTP handbook from internet. And also, you can refer the Tutorial and other Help files installed with QTP installation.


  • Try to understand basics of Object repository. You will become more familiar with using Object Repository once after start working on QTP automation.


  • Familiarize yourself using QTP add-ins (i-e selecting/deselecting specific add-ins).


  • Understand the basic units such as Test, Actions, external vbscript in QTP by going thro' the Help file and the Handbook document. Practice yourself by creating simple Test with one or two Actions.


  • practice yourself by recording and playing some steps using the sample application (Flight booking Application).


  • Try to understand the need for having multiple Actions in a particular Test.


  • Practice yourself creating Actions and splitting the Actions. And also, understand the need for having external reusable actions, and practice yourself using "Call to Copy of Action" and "Call to Existing Action".


  • Familiarize yourself with components such as Expert view, keyword view, Active Screen and Datatable.


  • Learn basics of vbscript by going thro' the vbscript documentation available in QTP help file, and be familiar with syntax of frequently used vbscript functions such as mid,instr and split.


  • Do some practice to have clear understanding of relation between Test Objects stored in object repository and the Vbscript statements showing in the expert view. You can do it by changing name of Test Object in OR and see the name automatically got changed in the expert view statement. And also, you can try to add/remove/edit some properties of Test Object in the Object Repository.


  • Understand the relationship between the Keyword view and the expert view.


  • Learn different types of Checkpoints and use them in sample script developed using the sample application. Intentionally put wrong expected result in the checkpoints to see how the Test result will look when showing checkpoint failures.


  • Learn to use multiple Object repositories (both Local and Shared), and also practice to get clear understanding of merging of Object Repositories.


  • Learn Recovery Scenario to handle unexpected behavior of application.


  • Read the Help file to get clear understanding of Datatable and parametrization. And also learn about Action iteration and Test iteration without any ambiguity. Practice it by creating Data Driven testing for simple login screen.


  • Start using Reporter.ReportEvent in the code to enhance the reporting of the results.


  • Use ObjectSpy to get familiar with finding properties of the Object.


  • Learn to change Test Settings and the editor settings. Here you should have clear understanding of which setting is applicable for the particular Test and which setting is applicable for particular instance of QTP installation.


  • Understand the need for Synchronization and try to use different ways (use of sync(), waitproperty, and exist) to achieve it.


  • Practice to use Step Generator,Function Generator and Active Screen to speed up the automation script creation process.


  • Learn about different types of recording modes and understand the need for them.


  • Learn how to create/use COM objects such instance of Internet Explorer browser and an instance of excel object.


  • Learn to use Debug feature effectively.


  • Understand the need for Regular expression and learn some frequently used regular expressions (e.g .*)


  • Learn about QTP automation framework creation, and try to create a framework best suitable for your needs.


  • Learn Automation Object Model and understand the need for them.


  • Learn about best practices (e.g always using reference path) and coding standards.


  • Go thro' the QTP forums (e.g www.sqaforums.com) and read the discussions to get familiar with QTP issues and solutions/workarounds.


  • Learn to connect with database table for checking the database content.


  • Learn basics of Descriptive programming (DP) which is the alternative for Object Repository (OR). Personally I won't recommend to use DP because it will create maintenance problem. But anyway we need to learn Descriptive programming in case we need to update any existing DP code.


  • Learn to integrate with Quality Center (QC).



I am planning to write more posts for explaining above topics in details.

If you want to read them you can subscribe to our RSS feed.

Read here if you are new to RSS feed.
More Articles...
eBook for learning Software Testing and QTP Automation.
Read more ...

Saturday, April 25, 2009

MySQL - Resolved null issue in query.


We have faced strange issue with MySql old version (version 4).

Our php file will pass a querystring variable "id". It can have a value or it can be empty in some situation.

Initially, we used below code,
$id=$_GET['id'];

$sql="select school_name from school_table where id=$id";
$result=mysql_query($sql);

It was working fine if the $id is assinged with a value.
It showed syntax error if $id is not having any value.

Below workaround resolved the issue.

Added below code above the query.
if ($id=="")
{
$id="null";
}
More Articles...

Read more ...

Resolving delimiter issue in PHP


All we know that server side coding can be delimited using any one of below two ways.
1. <? some code ?>
2. <?php some code ?>

It is always good practice to follow the second way, some servers may not allow the first way.

If your already existing code uses first way in many files, you can change the server setting to give support for the first way. It can be done by setting below option in php.ini file.

short_open_tag=on;

Use phpinfo() to find the location of php.ini file in your machine.
More Articles...

Read more ...

PHP - Disabling Display of Notice messages


Displaying notice type message will be helpful for improving development when developing websites using php.

But in production environment displaying Notice messages is not a good practice.
We need to disable them in production environment.
For doing this,we can set php.ini file setting as below,

error_reporting = E_ALL & ~E_NOTICE
It will allow to display all error messages (fatal,warning,parse) except the Notice type error.


If you are not sure about php.ini file location, use phpinfo() to find the location/path of the php.ini file.

Or alternatively, we can use "@" modifier before the variable name to suppress the Notice message related to that variable.
More Articles...
Read more ...

Friday, April 24, 2009

Understanding Object Repository in QTP (Quick Test Professional)


eBook for learning Software Testing and QTP automation
In my previous post , I have given some brief introduction to Object Repository.

In this post, I would like to give some more details about Object Repository in QTP.

Object Repository is a centralized place for storing Properties of objects available in AUT (Application Under Test).

Why Centralized place? And, Why we should store the properties of objects available in AUT?

First, I will explain below things which will be helpful for understanding answers of above questions.

- All software applications and websites are getting developed using many different components or small units (e.g textbox control in vb, input tag in HTML, webbrowser contorl in .net) which can be called as Objects.

- Each object will be identified based on the object type. And also, each object will have its own properties (e.g name,title,caption,color,size) for helping to identify by each of them. And also, each object is having specified set of methods.

- Some of the properties can be changed during run-time. These are known as RO (Runtime object) properties. And some of them can not be changed. They are known as TO (Test Object) properties.

- You can use ObjectSpy available in QTP IDE to see the TO properties & methods and RO properties & methods of any object available in your application. (Make sure that required add-ins are available).



If you see TO and RO properties of many objects in different applications using ObjectSpy, you will be in a position to distinguish between TO and RO properties.

- Since TO properties are used for uniquely identifying any object, QTP will store only the TO properties of any object in the Object Repository.

- QTP will store TO properties of any object of AUT in Object repository as Name&Value pair. You can refer the below screenshot.



- The Objects stored in the Object repository(OR) are called asTest Objects. Actually it is just equivalent to the corresponding actual object in AUT.

- All the Test Objects that are stored in Object repository(OR) are arranged in a hierarchical structure. (e.g Browser->Page->webelement).

- QTP will store the TO properties of the Objects in many different ways.

  • One simple way is, while doing Recording the TO properties will be stored to the OR.

  • Second way is, TO properties can be stored by pointing the mouse cursor to required object in the AUT.

  • Another way is manually adding the TO properties of the objects to the OR.



- Note that QTP won't store all the TO properties of the objects to the Object Repository. Only few properties will be stored to the OR, based on the setting done in Object Identification window. Refer the below screenshot. It can be opened from QTP IDE (Tools->Object Identification).



-Sometimes, QTP will store some additional properties such as index, location which are known as ordinal identifiers. Actually these properties won't be available in the object of AUT. It will be created by QTP automatically to distinguish two objects which are having exactly same TO properties. (e.g Some forms in the web pages will be have two submit buttons, one at top and another at bottom. QTP can identify them only based on location or index).

-Note that even QTP is storing TO properties based on properties of object of AUT (i-e real object), there is no need for all the TO properties to be available in RO properties collection also. (ie) QTP can derive (i-e do some manipulation) to get some new TO properties from one or many RO properties.

-Script can get TO properties of Test Objects using methods such as getTOproperty and getTOproperties. Even, TO property of TestObject can be changed using setTOproperty. But anyway, it will be valid only till exiting the execution. After completing the execution it will resume the actual TO property stored in the OR.
During run-time we can get the property of the runtime object using getROproperty.

-Till this point we have seen about storing the Test Objects in Object Repository.
During Run mode, QTP will use these stored properties for comparing them with properties of actual objects of AUT to identify them.

- These Test objects can be represented in the script as ObjectType and Object name. (e.g Window("Mozilla Firefox").Activate).

- The object repository will support editing of properties of Test Object and new properties can also be added to them.

- The value for the properties of the Test Objects in OR need not be a constant. We can parametrize the values so that the TO property can be dynamically changed for each iteration of execution.

Now we can come to our Initial question. By storing properties in the centralized place, maintenance and updation of Test scripts can be easily done whenever there is a change in UI (User Interface) of the AUT.
Assume that Login screen is used in around 20 Test scripts. If the Page name of login screen in changed, we need not make any change in all these 20 Test scripts. Just changing the property of Test Object in OR is enough.

Clear understanding of Object Repository is essential if you are willing to use QTP extensively. Because we may face lot of difficulties/challenges while working with QTP. We should have clear knowledge in OR to face/solve them. Just Recording and Playback won't help much. And also, Test Automation framework can be done very effectively only when you are familiar with understanding/handling of Object Repository.
eBook for learning Software Testing and QTP automation
More Articles...

Read more ...

HTML - Displaying Content in the same line using DIV tag.


Normally content within DIV tag will be displayed in separate line. (i-e) Line break will be added after the content.

For example, see the below HTML code.


line1 <div>line2</div>

The browser will dislay the above code as below.
line1
line2

If you want to display it in single line as "line1 line2", you have to use SPAN tag instead of DIV tag.

Or, we need to add style as display:inline; to the div tag for displaying it in single line.

line1 <div style="display:inline;">line2</div>


Updates on April 26:
After reading above post, my team-mate asked me why we need to use "display:inline" as SPAN tag can do it simply.

Today I came-up with a situation where "display:inline" is really needed. I wanted to display an image in the same line after a text formatted using <h4> tag. Here we can't use span tag, we should be able to use only the style "display:inline".
More Articles...

Read more ...

Thursday, April 23, 2009

Basics of QTP (Quick Test Professional)


As I explained in the previous post, QTP is widely/most popularly used Functional/Regression Test automation tool. It was developed by Mercury Interactive and acquired by HP.

But anyway, we need to do proper tool evaluation before selecting QTP for automating testing of our application.

Since QTP can support external add-ins, it can be used for many different applications.

Read QTP Tutorial at  QTPBook.Com

Some add-ins (e.g ActiveX, VisualBasic,Web) are built-in with QTP, and some other add-ins (e.g Java, .net, TE (Terminal Emulator))are external add-ins.

We can load only the required add-ins when opening the QTP IDE. So it will be helpful to improve the execution speed.

QTP will support Keyword Driven and Data Driven testing. We can create our own test automation framework also based on our own requirements for test automation.

It is very important to understand how QTP works. Because it will help to learn any other feature in QTP easily. And also it will help to design an effective automation framework and also it help to resolve any issue faced during automation script development and also during script execution.

I will explain it as below,

All we know that every test case should have Test Steps and Expected Results.

As QTP is used for executing these test cases, QTP also should have way for handling both Test Steps and Expected Results.

Handling Test Steps means QTP should be capable of navigating any path/page in any website or in any software application.
So, for doing this QTP should be able to recognize any control/object in any application/webpage. For recognizing the object, it should know the properties of those objects beforehand. It is achieved by storing the properties of the objects in a centralized place known as Object Repository.

While running the test script, the objects in the application are identified/recognized by comparing the properties of them with the properties stored in the Object Repository. By doing this execution of Test Steps becomes possible.

QTP is having Datatables (similar to Excel sheet) for supporting execution for multiple iterations of same steps with different data. For example, assume that we need to execute two test cases, one for logging into a website using UPPER case username and another test case for logging into a website using lower case username.

For executing these two test cases, the steps will be same. The only difference is in the test data.

It can be easily done in QTP by putting these input usernames in Datatable and make the Script to execute it two times.

Next, we need to think about handling Expected Results. The purpose of testing is comparing the Actual result with the predefined Expected Results. It is achieved by using Checkpoints.

There are many checkpoints available in QTP. They are, Standard Checkpoint,Text Checkpoint, Bitmap Checkpoint, Database Checkpoint, accessibility Checkpoint and XML Checkpoint.

Actually QTP can be used simply as Record and Play type tool for automation of simple steps on simple applications. But it should be extensively used by writing user defined functions and many other features to get more benefit from it.

QTP is not using any Proprietary Script. It uses commonly available VBscript. So writing script will be simple. And also, vbscript is commonly used in many places such as Web development (ASP), and in windows administration works. So we can easily find lot of already available user-defined functions and help articles in the Internet.

And also, QTP supports COM model. i-e Any methods and properties of any COM based application can be easily accessed from QTP. For example IE(Internet Explorer) and Excel Objects can be created within QTP script. It is applicable for QTP itself.
i-e Object of QTP itself can be created and handled. It is known as Automation Object Model.

Basically QTP is a functional/Regression testing tool. But it can be indirectly used for testing performance also. (i-e QTP scripts can be called from performance testing tool "Load Runner"). And also, QTP is having limited performance testing options such as start and end transactions which will be helpful to find execution time for particular block of steps.

QTP can be closely integrated with the Test Management Tool Quality Center (QC). QC can be effectively used to run QTP scripts in multiple remote machines to complete execution of many test scripts in less time.


The user friendly IDE which has Keyword view, Expert view, Datatable, Active screen, object repository editor/manager,step generator, function generator,object highlight feature, intellisense, recovery scenario manager, update run feature and simple Test/Action handling features makes the Script developer/execution work easy. The IDE is integrated with useful tools such as ObjectSpy. The IDE has standard development features such as Debug.

Click here to buy an eBook for learning Software Testing and QTP Automation

More QTP articles...

More Articles...

Read QTP Tutorial at  QTPBook.Com


You can bookmark this blog for further reading, or you can subscribe to our blog feed.
Read more ...

Wednesday, April 22, 2009

Basics of Session and Cookies


We know that Webpages are getting displayed using stateless Protocol.
So there should be someway for keeping the session of the user navigating the webpages within a website.

Session variables and Cookie variables can be used for this purpose.
Basically Session variables are maintained by webserver. (i-e)Physically the value of any Session variable will be written to a file located in the web server.

In php, we can set/use the session variable using $_SESSION. Say for example, if we need to put the user email (e.g $email) in session, we can use it as $_SESSION['email'] whose value should be set as $_SESSION['email']=$email.

Whenever assigning this session variable, a file will be written to the web server at location specified by session_path variable in php.ini file.

Suppose 1000 users are using your website, there will be 1000 files created for storing one session variable.

So it will become a big memory issue if you are not managing the session properly. (i-e) we should unset the session variables during logout. Appropriate session timeout value should be specified to enable automatic expiration of the session if the user forgets to logout. And also we need to take additional care to manage session if security is more important for your website.

Or alternatively we can use cookie variables which are stored by the web browser in the users machine. As the cookie variables are stored in the client machine, it can be available till it gets deleted either by browser setting, or by the code or by the user manually.

Since cookie variables can live even after closing the browser session, it can be very useful for improving user experience. (i-e) Lot of data related to user preferences can be stored in the cookie. So whenever the same user logs in, his previous settings can be applied automatically by using these cookie values. For example if the user allows the website to store his password in cookie variable, he can log in to the website without typing his password again.

In php, cookie variables can be set using setcookies function.
But anyway, privacy is important for you, you can restrict the cookies by changing the browser settings.
More Articles...
Read more ...

PHP - Resolved the issue of setcookies not setting properly


PHP is having a function called setcookies for setting a value for cookie variable.
The sample syntax for using this function is,

setcookies("username",$username,time()+3600);
Here, username is the cookie variable (i-e $_COOKIE['username']) and $username is the value to be assigned for this cookie variable.
time()+3600 represents that this cookie variable will be expired in 1 hour.

We faced an issue when we try to change the value of cookie varibale using this function in between the php code. This situation is arised as our requirements mandated the change in cookie value after some steps in the php code. The issue is, cookie value is not updated. "echo" of the cookie variable showed only the old value.

When we did further analysis, we noticed that cookie value is set correctly only when we refresh the web page two times. From the internet search we came to know that it is the expected behaviour. As the cookie will be sent as part of the Header, it should be sent before sending any content. Since we are using setcookies in between the code it seems some content has been sent already before setting the cookie.

So to avoid this issue, just we created one dummy php file (e.g redirect.php). In the code after using setcookies we put a code for redirecting the page to this redirect.php instead of redirecting to the intended file. In this redirect.php we put a code for redirecting to the intended file.
This approach solved the issue completely without any further issues.
More Articles...
Read more ...

Tuesday, April 21, 2009

Importance of Software Testing


In Internet, We can see lot of articles explaining/listing loss made by poor low-quality software products.

How will you feel if a bug in bank software shows your bank balance as 0 instead of some thousands?
And if you are a student, what will be your state if your mark-sheet shows your score as 0 instead of some good score?

Here, we will be feeling good if we see some notification or message instead of seeing wrong data.

For example, a message such as “Not able to show your balance due to some unexpected error “ will do more goodness than showing balance as 0 in our first example.

Similarly, a message such as “Couldn't print your mark-sheet because of unexpected issue” will be useful than showing score as 0 in our second example.


Testing plays an important role to avoid these situations.

So, we can say that testing is necessary or important even when it couldn't guarantee 100% error free software application.

i-e Testing may not fix the issues, but definitely will help to provide improved user-friendliness.

Also,

- Cost of fixing the bug will be more if it is found in later stage than it is found earlier.

- Quality can be ensured by testing only. In the competitive market,only Quality product can exist for long time.

Testing will be necessary even if it is not possible to do 100% testing for an application.

One more important reason for doing testing is user/production environment will be completely different from development environment.

For example, a webpage developer may be using FireFox as browser for doing his webpage development. But the user may be using different browser such as Internet Explorer, Safari, Chrome and Opera.

The web page appearing good in FireFox may not appear good in other browsers (particularly IE). So ultimately, user will not be happy even if the developer put more efforts to develop the webpage. As we know that Users satisfaction is more important for growth of any business, testing becomes more important.
So we can assume the Testers as the representatives of the Users.

But anyway, as I mentioned in my previous post testing will be useful only when it is planned correctly and if proper communication between developers and testers is established.
More Articles...


Click here to buy an eBook for learning Software Testing and QTP Automation
Read more ...

Monday, April 20, 2009

PHP code for preventing session hijacking


The hacker may get session id of our browser in someway, and then using this session id they can continue our session in their browser.

So this session hijacking will allow the hacker to use our login restricted web pages without knowing our login credential.

Say for example, the hacker can read your emails from their browser itself if they just know session id of your browser.

Find below the sample code written in PHP for preventing session hijacking.



function prevent_session_hijacking()
{
//code for preventing session hijacking
session_start();

//Regenerate SessionID for avoiding Sesssion Fixation

if (!isset($_SESSION['initiated']))

{
session_regenerate_id();
$_SESSION['initiated'] = true;

}

//for preventing session hijacking.
if (isset($_SESSION['HTTP_USER_AGENT']))

{
if ($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT']))

{
exit;

}

}

else

{
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
}

}



We have to do many other Security testing (e.g sql injection, Cross-site scripting) to make sure your website is safe for your users.
More Articles...

Read more ...

Sunday, April 19, 2009

Dynamically changing/displaying web page content using javascript without refreshing the page


Sometimes we may need to change the content displayed in the webpage frequently.
Javascript will enable achieving this without the need for refreshing the webpage.(i-e without requesting the page again).

Below steps are needed for doing this.
- All the contents should be stored in a Javascript array.
- Body onLoad event will call a function thro' a javascript method setInterval().
- setInterval() method will behave similar to setTiemout() which will call a function after preset time. Additionally setInterval() will call the function repeatedly.

You can refer the below code. This blog is using the similar code for displaying Quotes in side bar.

<html>
<head>
<script type="text/javascript">
var quoteIntervalId = 0;
var arrQuotes=[
'quote1',
'quote2',
'quote3',
'quote4'];
function displayQuote ( )
{
quoteIntervalId = setInterval ( "showQuote()", 1000 );
}

function showQuote ( )
{
var randnumber=Math.random ( )*1000;
randnumber=parseInt(randnumber);
var count_quotes=arrQuotes.length;
var quoteindex=randnumber%count_quotes;
document.getElementById("quotemsg").innerHTML = arrQuotes[quoteindex];
}

</script>
</head>
<body onLoad="displayQuote();">
<div id="quotemsg"></div>
</body>

</html>


Here,
- arrQuotes is a javascript array used for storing all the content when requesting the page.
-Call displayQuote() function from onLoad event of body tag.

- The displayQuote()function uses setInterval() to call another function showQuote after 1000 milli seconds (1 second) repeatedly.

- The showQuote() function uses Math.random() to generate a random number, and used modulo operator(%) to normalize/limit the random number within the number of items in the arrQuotes array.

- Take the content from the array based on this normalized random number and InnterHTML of a div tag ( with id quotemsg) is set with this content.
More Articles...

Read more ...

Javascript code for preventing user from copying content from webpage.


Find below the javascript code for disabling Mouse right click in web browser to prevent user from copying the content.

Buy anyway the content can be copied from many other ways such as from view source.

This code won't help if the user disables the javascript in his browser.

I am just curious to know whether any code/way available to prevent webpage content copying completely.





<script language='JavaScript1.2'>
function disableselect(e){

return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</script>


More Articles...

Read more ...

Saturday, April 18, 2009

SQL query for deleting duplicate records in parent table without affecting child table


We need to take additional care when deleting duplicate rows in a table if the table is related with another table and there are no proper foreign key constraints available.

Consider below two tables. The parent table is having duplicate rows. If we just blindly delete the duplicate rows in the parent table, the child table rows associated with the duplicate parent row will be in trouble.
So to avoid this issue we need to update the child rows with available parent row ids once after removing duplicate rows in the parent table. Anyway the best way is defining appropriate foreign key constraints.

Find below the DELETE query for deleting duplicate rows in the parent table and UPDATE query for making necessary changes in child table once after executing the DELETE query.



Delete
from parent_table
where id not in
(select min(id) from parent_table P2 where P2.Name=parent_table.Name)

update parent_table p,child_table c set c.parent_id=p.id
where c.parent_id not in
(select c.parent_id from child_table c, parent_table p where c.parent_id=p.id)
More Articles...

Read more ...

Web Development Best Practices


High speed Internet connection and Technology Giants such as Google and Apple make most of the people to use internet daily.
So, Web Development is getting important place in Software development. We need to consider many factors when doing website development.
- The most important factor is knowing about target audience. It will be helpful to provide more user-friendly UI (User Interface). Because different type of people will prefer different type of navigation / screen design.
- We should know which factor should be given more importance, whether it is "performance" or "look & feel" or "user-friendliness" or "cost".

- Now-a-days it is important that the websites should be search engine friendly. (i-e) The webpage should be visible not only to human beings but also to the bot/crawler of major Search engines such as Google and Yahoo. Please note that bots of some search engines can not follow links listed using javascript menu. If you still want to use javascript menus, you can provide site map for enabling the bots to crawl your pages. Creating site map is easy. Just we need to list all the links in a text file or xml file or html file . Then we have sumit the path of this sitemap file to the Search Engine thro' their webmaster tool.

-Since many people started using iPhones, it is important to make your website iPhone friendly if you want them to see your website. In this case you can provide separate CSS style sheet for iPhone and normal browsers. And you can dynamically load appropriate CSS file based on UserAgent string.

- If you are developing website for financial transaction you should think about using "https" and preventing cross-site scripting, sql injection, session-hijacking and any other security related steps.

- We should keep in mind that the users may not have the browser/screen resolution/color settings/browser settings same as ours. It is true that some users will not enable javascript in their browsers, and I heard that some users are still using some text based browsers. So it is very important that we need to consider all these factors while developing the website. We should write code such that different code should act based on settings of user browser.

- The very important difference between web development and other desktop applications is, we should always keep in our mind that we are working on stateless protocol. (i-e Clinet browser will not having any other relationship with webserver once after sending the web request, similarly the webserver will not have connection with client browser once after sending the response string). We should take all necessary actions (e.g use of Sessions, cookies) to maintain user session.

- We should use CSS (Cascading Style Sheet) to enable easy change of look and feel of website. You can refer this article for knowing about best practices for CSS use.

- Menu and any other repeatedly used items should be kept in separate file and it should be included in all other pages.

-Javascript validations should be used extensively to save time by contacting webserver for doing any validation which can be easily done in the client side itself. But anyway if security is more important for your website then you should still do server side validation also.

-Ajax should be used extensively to avoid unnecessary refresh of entire page, just for updating one part of the page.

- Loading indication should be shown whenever backend operation (database query) takes more time.

- There won't be any broken links in the website and HTML tags should follow standards. You can use w3c validation to verify it.

-Always put all your javascript functions and references such as CSS file inside the HTML Head tag as the Head tag contents will be loaded first. If it is not possible to access Head tag, then atleast put them at the bottom of the body tag (i-e just before the </body> tag)

- Design the UI properly to improve user experience.

- We need to take additional care when handling single quotes and double quotes in HTML code , in Javascript function and also in Database queries. Use proper escape characters to handle them effectively.


Apart from above practices, we need to follow all other coding standards, such as
writing clear inline comments, keeping appropriate indents for the nested loops and
appropriate naming conventions for variables.

And also, we need to write all details of lesson learnt from any issue, in a document or in a database as a Knowledge base for further/future reference by the Team.

Click here to read Best practices in QA - Software Testing
More Articles...
You can bookmark this blog for further reading, or you can subscribe to our blog feed
Read more ...

Friday, April 17, 2009

C# - Performance difference between use of Datatable and use of external database


C# is having Dataset and datatables which can be used much similar to external database (eg. ms access database (.mdb)).

Even when the database is more optmized to handle query for selection and sorting, it is advisable to use built-in Dataset/Datatables.

Because I/O operations between the C#/.net application and the external database will consume significant time which will ultimately reduce the performance/speed of execution.

I can see significant performance difference between these two approaches when we did some performance testing using the code developed based on database and the code using built-in datatables.

But I am not sure whether Dataset will be useful if we need to handle large amount of data.
More Articles...

Read more ...

Thursday, April 16, 2009

URL for checking usage of Broadband provided by BSNL


If you are having broadband connection provided by BSNL , you can verify the usage up-to-date by logging in to any one of two below urls.
www.data.bsnl.in

http://bbservice.bsnl.in/

If you are using it first time you should get portal id from BSNL. For getting portal id we can call the BSNL customer care number 1500.

For any other online services related to BSNL, we can go thro' below website address.
http://chennai.bsnl.co.in/onlineServices.htm

Find below the url for seeing the bsnl mail.

http://mail.bsnl.in/
More Articles...

Read more ...

How to dynamically change attribute (e.g height) of HTML tag based on screen resolution using javascript?


Sometimes we may need to specify the attributes such as height and width of HTML tag in pixels instead of specifying it using percentage.
In this case, the HTML page will appear differently in different screen resolution of the user's computer monitor.

To avoid this issue we have to dynamically change the attributes of the HTML tags based on the screen resolution. It can be done using javascript.
In javascript, screen resolution can be identified using screen.height and screen.width.

Find below the sample code which explains how to dynamically change the attributes based on Screen resolution.

<html>
<head>
<script language="javascript">
function adjustHeight()
{
var ref_height='768';
var actual_height=screen.height;
var m_factor=actual_height/ref_height;

var h1=document.getElementById('id1').getAttribute('height');
h1=h1*m_factor;
document.getElementById('id1').setAttribute('height',h1)
}
</script> 

</head>
<body onLoad="adjustHeight();">
<table >
<tr height="80" id="id1" bgcolor="#009900"><td> </td></tr>

</table>

</body>
</html>



Explanation for above code:
- Initial design time height for TR tag is 80.
- onLoad event of body tag calls javascript function adjustHeight()which will change height of this TR tag based on height of user's screen.
- adjustHeight will find a multiplying factor based on predefined reference height and the height of the user's screen. And it will use setAttribute to change the height of TR tag based on this multiplying factor.
More Articles...
Read more ...

Wednesday, April 15, 2009

Best practices in Software Testing


There are lot of materials available in internet to explain best practices in Software Testing.

Here I am writing only the very essential things for medium level projects based on my experience/view point.

  • We should start our testing activities at beginning of Software development itself.
    Understanding Scope/purpose of the project will help to judge the degree/level of testing required.

  • Testers should go thro' the requirements in detail without missing any points given by the client before writing test cases. If they find any ambiguity in the requirement they should get clarification from the business instead of doing any assumptions.

  • The test cases should be updated immediately once the client gives new requirement or changes the requirements.

  • The test case document should cover all the requirements even if some requirements are non-testable. These non-testable items should be marked as non-testable. Keeping traceability matrix document will helpful to achieve this.

  • The Test case document should help to clearly identify hierarchy/arrangement of test cases. It should have clear approach to arrange test cases if many test cases exist with similar steps. It is not advisable to copy & paste the similar test cases many times, instead we can specify only the additional/different steps.

  • Description of each test case should be written clearly after understanding the context/module of description. Steps should be written only after manually executing them. Expected results should not have any ambiguity. If required, Prerequisite/preconditions should be mentioned.


  • Planning and creating test plan document is essential even for small short-term projects. The test plan document need not contain all the details, but it should contain at least very basic components such as scope,schedule, risks, environments, testers


  • Planning of development/test/staging environments should be done clearly. And it is very important to move the code and maintain version of code in each environment without any ambiguity/confusion. Testers should know which version of code/data is available in each environment


  • Test execution should be done carefully based on the test cases. It is very important to use appropriate test data. It is better to create different set of test data during test case creation itself. The test data should cover valid format,invalid format and boundary values.
    Test result(pass/fail) should be clearly updated for each test case. It is good practice to mention Actual behavior if the test case fails.

    The test results should be communicated to the other parties (developers,business/client) daily even if all the test cases are not executed. In this case, we should add a note to indicate that the test execution is still in progress.

    The test execution summary document/mail should clearly mention date of execution, environment, test name and test result.

  • In case, most of test cases are getting failed continuously, there is no meaning of continuing the execution. Execution should be resumed once after fixing the major issues.


  • It will be nice if we highlight the testing status (pass,fail,yetToStart) in appropriate color. But anyway, just highlighting the test case with appropriate color without specifying status is not a good practice. Because while taking single color printout of the test report, it is difficult to see the status from the color.



  • It is good practice to do some adhoc testing in addition to the test case execution.


  • Clear/proper communication/co-ordination within the Testing team and also with other teams (developers, client/business)is very essential.

  • The bug report should be prepared very clearly with all essential details, especially with the steps/testdata for reproducing the bug. The bug report should help the developers to reproduce the bug and to fix it. Providing screenshots of error message and screenshots of each step will be useful.


  • Doing re-test and small regression test is essential whenever a reported bug is fixed


  • It is not good if we do all the testing manually, as manual testing will take more time/effort and it is difficult to manage, and also it not consistent or repeatable. So it is better to automate the test cases using test tools such as QTP(Quick Test professional). Even we can use simple shell scripts and vbscript to automate some part of the testing.



Updates on September 18, 2010

Based on LinkedIn discussion, I am adding below things also.


  • We need to setup Test Environment almost similar to the production environment. It will be nice even if we have same hardware set up.


  • Never make any assumption whenever communicating with developers and business analysts. Convey your understanding to make sure that your understanding is correct.


  • Make sure to do an impact analysis, take help of developers as needed


  • Prioritizing test cases is must based on application features being changed/ added




eBook for learning Software Testing And QTP

More Articles...
Read more ...

Importance of Software Test Automation using tools such as QTP


Software Testing plays an important role in Software Development lifestyle.
As I mentioned in my another article, doing manual testing is not enough. We should go for Automation Testing also.




  • "To Error is Human" is the fact which drives the need for automation testing. Because, manual testers may not execute the test cases correctly. There will be lot of possibilities for making mistakes. They may give wrong input data due to typo, or they may not notice the actual behavior of the system correctly, or they may not report the test result correctly, or they may miss to execute some test cases, or they may forget to run some preconditions, or they may change the sequence of test case execution in case sequence is important.


  • Another important factor is, Automation test scripts will be used as a way of storing domain/project/task Knowledge gained by the Test Engineers. Say for example, if a Tester works in project for one year, he might have spent more time for learning the domain, purpose of the project, modules in the project, flow of all functionalities. He will be familiar with known issues and challenges.
    If this Tester leaves from the project, the knowledge gained by him also will leave.
    It is very difficult for the newly joining Tester to understand everything from the Test Case document.

    If automation test scripts are already available then the new Tester can just start the testing by running the automation scripts, without gaining much knowledge about the project.

    He can understand the flow/data by seeing the execution of the automation test scripts. But anyway, he should gain project/domain knowledge to enhance/update the automation scripts further.
    So we can say that test automation is a way of storing knowledge.


  • Automation tool such as QTP (Quick Test Professional) has feature for storing screenshot of each and every page navigated during the execution. So it can be used as a proof for completion of testing, and also we can refer the screenshots of previous executions if there is any need to refer them.


  • Test report can be automatically written to a customized report page which will ensure accuracy of the report and also it can improve look & feel of the report.


  • The very important advantage of automation testing over manual testing is, execution speed. Test execution can be completed quickly and also we can execution the scripts in night time also without human involvement. So ultimately total time needed for testing can be reduced which will significantly help for timely project completion.

  • There may be requirement of doing some testing at specific time. It can be easily achieved by putting execution of those automation test scripts in a task scheduler/crone job. The tool such as QTP supports automation object model to achieve this.


  • The functional test automation scripts will be useful for doing performance testing also. Because many performance test tools will support reusing/calling of these test scripts.


  • Some type of testing involves comparing large amount of data between previous version and current version as part of regression testing. Practically it may not possible for doing it manually. This problem can be easily solved by simple shell script or any other scripts such as vbs, wsh.


  • As the automation test tools support Data Driven Testing, Test execution can be done repeatedly with many different data sets.



There are lot of automation test tools available for doing Functional, Regression and Performance Testing. Test complete, SilkTest,SilkPerformer, QARun, QALoad, TestPartner, WinRunner, LoadRunner, QTP, Rational Robot and openSTA are some of them. QTP is most widely used now as it supports vbscript and it can be used for testing many different applications just by adding required add-ins.
Buy eBook for learning Automation Testing
More Articles...

You can bookmark this blog for further reading, or you can subscribe to our blog feed.
Read more ...

Tuesday, April 14, 2009

Always explicitly use $_GET when using querystring parameters in PHP.


Consider below url.

www.yourdomain.com/pagename.php?id=10

In pagename.php file, we should add below code to use this querystring parameter ‘id’.

$id=$_GET[‘id’];

Based on server setting or php.ini values, we can use $id even without using above code.

(i-e PHP variable ($id) will be automatically created based on name of the querystring parameter (‘id’) and querystring value will be assigned to this PHP variable.)

But the good practice is, we should always use the explicit assignment (e.g $id=$_GET[‘id’];) to avoid unnecessary issues which will occur if the server setting doesn’t allow the automatic assignment.
More Articles...

Read more ...

How to change Row of Data into Column Data in Excel?


Sometimes we may need to rearrange the Data arranged in a Row into Data under columns.




Refer the above screenshot showing Employee name and Employee Id in separate rows.

If we want to rearrange this data into columns, just follow below steps in Excel.

1. Select the existing Rows and Copy.
2. Put the Cursor at required place/cell and then do mouse right click.
3. Click "Paste Special" in the Context menu.
4. Below pop-up Dialog will appear.


5.Check "the Transpose" and click 'OK'. Now the Data will be rearranged under columns as shown in the below screenshot.


More Articles...

Read more ...

Search This Blog