HTML 5 New Form Elements and its Benefits

HTML 5 has some fantastic changes to the form elements which I feel is surely going to make the life of the developers somewhat easy as now they might have to write less code to do some of form validation work. Use of these HTML Tags as part of form means you write less code and do less amount of testing since the real implementation and validation is now done by the browsers.

In all there should be around 10 to 15 new form HTML tag elements which I feel is going to be implemented as part of HTML 5 Specs. Below are the some of the new form elements which I feel are going to be introduced in HTML 5,

· search – This is going to be used for Search text field.

· tel – This is going be used as text field which will accept telephone numbers. It also has pattern attribute to customize according to one’s requirement.

· url – This field is going to accept the url of the site.

· email – This field will accept only email addresses. It has the attribute which can accept multiple email addresses in the same field.

· color – Shows up the color picker control.

· number – This field designed to accept the numerical input. It supports the pattern wherein the user can be restricted to give only numbers in the field.

As of now these HTML 5 elements are not fully supported by browsers, but I have tested this in latest version of Google chrome and Firefox, they do support these tags.

Below is the sample code which I tried in chrome and Firefox,

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 Form Elements</title>
</head>

<body>
<form method="post" enctype="multipart/form-data" name="form1">
    <p>
        <label for="search">Search:</label>
        <input type="search" name="Search" id="idsearch">
    </p>
    <p>
        <label for="tel">Phone:</label>
        <input type="tel" name="Phone" id="idphone">
    </p>
   <p>
        <label for="url">Website Details:</label>
        <input type="url" name="website" id="idurl">
    </p>
    <p>
        <label for="email">Email:</label>
        <input type="email" name="email" id="idemail" multiple>
    </p>
    <p>
        <label for ="number"> Lucky Number : </label>
        <input type="number" name="luckynumber" pattern="int">
    </p>
    <p>
        <label for="color">Select color:</label>
        <input type="color" name="colorn" id="idcolor">
    </p>
    <p>
        <input type="submit" name="send" id="send" value="Submit">
    </p>
</form>

</body>
</html>

Don’t me believe, copy paste this code in notepad and save it as html document and open this in Firefox and chrome and use your testing mind and see for yourself how much testing and development efforts you can save when you use these tags as part of your development practice.

Comments

My New Year Resolutions – 2012

I am also one of those guys who year after year had some resolutions and then year after year has broken it for various reason.Now that I am maintaining my own blog, I feel its good thing that I should note down  the list of tasks which I believe I should focus on in 2012.There are number of things which I want to do in 2012 both at personal and professional level.

Some of the stuffs I will be focusing on in 2012 will be ,

  • For some time now, I had a desire of building something like Facebook or Twitter ,though the skeleton is somewhat ready, I need to focus more on dressing the skeleton appropriately.I really wish to spend more time on this in 2012.
  • I think I should work more hard this year in understanding CSS/HTML/HTML5/Javascript and how these things are rendered by browsers.I think this is one of the most interesting areas which every performance engineer should focus on at some part of their career.
  • I think I should be writing more on the Performance Engineering topics which has always been my interest.I will also be writing about as how to use/identify/verify/fix performance issues with LoadRunner/Silk Performer.These are my Favorite tools and will continue to be.I just love the way these tools work and have been designed.
  • My blog  needs some attention from me,lot of people and spammers have complained that I don’t maintain “About me” and overall my site sucks in terms of look and feel.So I will working on to improve my site. I will see if I can convert this site to full fledged knowledge repository site.
  • On personal level, I feel I need to practice more on controlling the emotions and concentrate more on my health.2011 was one of most bad year for me when I think about it in terms of health issues.
  • I will be watching more movies, first day first show and spend lot of time with my family even if this means doing less work and giving up projects.

Finally I am thankful to all friends, colleagues for making my last year 2011 a good one.

Comments

5 Reasons as why HTTP Debugging tools should not be used for preparing Load Testing Scripts.

In Recent times I have seen a kind of trend where in performance testers use tools like fiddler/yslow/httpwatch for scripting purpose in spite of having fully licensed version of the LoadRunner or other performance tools.I find this approach to be somewhat immature and prone to many errors if done by someone who do not understand performance engineering concepts or someone who does not understand the semantics of the web communication. I also find this kind of trend bit disturbing and harmful to the load testing industry for many reasons. I will list down some of the reasons why I feel this is a very bad idea and why one should not take this way for scripting purpose for preparing their load testing scripts.

I have encountered many times in my career where in the application in spite of working with supported protocol do not get recorded by the load testing tool. On further analysis of the issue, I did come across certain findings that either the setting which we use for recording the applications were incorrect or we were recording in the unsupported environment or it was just that firewall or DEP or some antivirus software setting were blocking the recording. So for sake of this post I am not writing here anything on as how I troubleshoot recording problems but will surely take some time later on to write on this as well. It’s interesting topic and deserves a separate post. So let me go back to original purpose of this post and write some of my thoughts why one should not use fiddler or any other HTTP Debugging tool to script a load testing script,

1. Tools like Fiddler/Yslow are the http debugging tools and not the scripting tools. They show http requests as resources are downloaded and interpreted by the browsers. Since page contains many resources, it becomes hard to tag these resources to the main request unless you are page author. Since the requests captured by these tools are context less and are not orderly distributed so I feel it cannot be used for scripting purpose and so they cannot replace the load testing tools.

2. Building the post requests from these tools is somewhat harder compare to get requests though not completely impossible depending upon the type and complexities of applications.

3. Since requests are displayed context less or in uneven order, correlation or capturing dynamic values is somewhat hard and prone to lot of errors resulting in many hours being wasted.

4. These types of tools follow the web standards and to know and understand information generated by these tools in real sense one needs to know and understand various RFC’s involved in the web communication. I have seen most of the Performance testers are unaware of these standards.At least this is my observation. It has taken years for me to understand as how web communicates.

5. From project finance prospective, we should not forget that we are paying five to six figure amounts to the licensed load testing tool vendors for using their product, so it makes more sense to ask them to fix these recording issues rather than using HTTP Debugging tools for scripting purpose. Also it looks bit odd when we use Open source HTTP Debugging tools to script when we have licensed version of the load testing tool. If you have program management office or PMO, who are auditing your projects, then they are surely going to scream on you for wasting so much of amount on load testing tools and not using it to their full potentials or capabilities.

Finally I would like to mention here is that this post is more about using right tools for the right job. HTTP Debugging tools are for debugging the web http communication, so I suggest let’s use these tools for debugging and load testing tools for preparing load testing scripts. In case for any reasons, if you are unable to record the script in spite of having supported protocol, then by all means you have all the rights to shout at the vendor and get the issue resolved.

Comments

10 Reasons as why your correlation fails

If you are doing performance testing, then I assume that you for sure know as what correlation means and how to do it. So I am not going to write anything on this. I know for sure that many times it happens performance script which runs perfectly fine in local machine, often fails miserably during the load test often throwing error saying that correlated value could not be found or parameter size is insufficient so increase the parameter size. Having worked with number of various protocols/technologies, I feel there are many reasons as why your correlation can fail ,so I will try to list down some of the reasons which I feel one needs to investigate in case his correlation is failing,

1. We have specified left and right boundaries incorrect. Sometimes it so happens that we miss to specify the special characters like trailing slash, comma etc. in boundaries. It is one of simple error which quite often we do while scripting.

2. We have not placed the function which does correlation at the right place that is right before the request which generates the dynamic value for the first time. This is also one of most common mistakes I have seen people doing.

3. We have not used the attributes of the function correctly. For example, value is getting generated in headers and we make the function search for value in body part of the response.

4. We have used left and right boundaries that are too generic and there are many instances of such boundaries in the server response for that request. In other words boundaries are not unique For example, if you have a form with many fields and if you give boundary as below, then it is bound to fail.

   1: web_reg_save_param (“LB= value”,”RB=,”, “Ord = 1”, LAST);

5. If the page returned as a server response is different than what we were expecting during replay, then obviously our correlation is going to fail. Since response page content will be different, function will not be able to find boundaries it requires to succeed.

6. If the size of the parameter where we are storing the dynamically captured value is less than actual size of the parameter returned by the server, then our correlation is going to fail. For example, let’s say we have parameter A and we allocate 1000 bytes to store the value and if the actual size of A is more than 1000 bytes, then our correlation is going to fail. Another good example of this is view states correlation.

7. Sometimes it so happens that we use incorrect data in our tests and due to this data, we do not get the page what we were expecting, and this error on our side also shows up as correlation failure in the test run. Sometimes we try to correlate client side generated values. I have made this mistake at some point of my career.

8. We really have performance bottleneck in the system. Quite often it happens that test runs fine for certain duration and then suddenly we see correlation failures for some or all of our functions. This is also one of area we need to investigate in case you see correlation failure after a certain period of time during the test.

9. We have not correctly replaced the parameters captured in the script.

10. Finally the function in itself has bug and due to this bug it might not be behave as it should. Failure to capture correctly view states by most tools during early days of ASP.Net is good example of this.

These are some reasons which I can recollect now due to which correlation can fail. I am sure that these reasons applies for all tools which are used for doing performance testing in all domains and all technologies.

Hope this helps.

Technorati Tags:

Comments

Javascript:Check if browser supports HTML 5 Geolocation Object

Geolocation Object is one of the cool features of the HTML 5.It is definitely going to make life easier for companies or sites which are predominantly in B2C category who can now make more bucks compare to other domains as they can now chalk out unique location based strategy for their customers.In addition to these domains, Geolocation can also used for various other purposes like security/tracking the missing people etc. though other techniques of tracking devices like using GPS/Cell id etc. are also as effective as Geolocation.But I guess Geolocation technique used via browsers will be one of the most cheapest ways of implementing location based strategy provided users gives the consent for tracking their locations.

However I would like to highlight here that W3C standards for some reasons have suggested implementation of  this object with caveat that information obtained via geolocation might not be fully accurate enough.Though I agree to this and consider it as fair enough suggestions given that depth and breadth of the pattern of its usage across various devices and situations varies.So in layman terms, it cannot be used legally with additional data to substantiate the proof of the location.But again benefits outweighs the risks here and that’s the reason I feel its one of the best things that has ever happened to web in recent times.

While experimenting with Geolocation Object of HTML 5, I wrote the small piece of JS code which I believe can tell us whether the browser supports Geolocation object or not.

Below is the sample HTML Empty code which loads the checkgeo javascript and dynamically creates the p element and then writes the user agent information giving the message whether the user agent supports Geolocation object or not.

The function checkgeolocationobject is part of checkgeo.js file and it needs to be present in the JS file.You can also have this function in the script tag of the HTML page.

<!DOCTYPE HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>HTML 5 Geolocation Check</title>
<style type="text/css">
p{
    font-family:Verdana;
    font-size:16;
    font-weight:bold;
}
</style>
<script type ="text/javascript" src="js/checkgeo.js">
</script>
</head>

<body onload="checkgeolocationobject()">

</body>
</html>
 
The Javascript piece which checks geolocation objects is as below.
function checkgeolocationobject(){
    if(window.navigator.geolocation){
        var para = document.createElement('p');
 var message = document.createTextNode("Yes we support Geolocation fully for "
 + navigator.userAgent);
        para.appendChild(message);
        document.body.appendChild(para);
        document.styleSheets[0].addRule("p", "color:blue", 0);
    }
    else {
        var para = document.createElement('p');
var message = document.createTextNode("No we do not support Geolocation fully for "
 + navigator.userAgent);
        para.appendChild(message);
        document.body.appendChild(para);
        document.styleSheets[0].addRule("p", "color:red", 0);
    }
}

 


Technorati Tags: ,

Comments

Simple CSS Horizontal Menu

Horizontal Menu’s are simple in design and do not confuse the users with respect to navigations.Since words are read from left to right/Top left to bottom right in the computer screen, I feel having horizontal menus somewhat enhance your site’s user experiences.Below is one of the simple CSS code which I tried and worked for me while building horizontal menus,

<!DOCTYPE HTML>
<html>
<head>
<meta charset=”utf-8″>
<title>Sample Horizontal CSS Menu</title>
<style type=”text/css”>
#idmenudiv {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    text-align: justify;
    margin:20px ;   
    padding: 15px;   
    width: 80%;
    overflow: hidden;
    position: absolute;
    visibility: visible;
    z-index: auto;
    height: auto;
    border:solid #55DFAA;
    border-radius:8px;
    background-color: transparent;
   
}

ul li a{
    margin-left:20px;
    margin-right:20px;   
}

li{
    display:inline;
    list-style:none !important;   
}
A:link {text-decoration:none}
A:visited {text-decoration: none}
A:active {text-decoration: none}
A:hover {font-size:16; font-weight:bold; color:#008080}

</style>
</head>

<body>
<div class=”clmenudiv” id=”idmenudiv”>
<ul class=”clulmenu” id=”idulmenu” dir=”ltr” lang=”en”>
    <li ><a href=”http://www.google.com” title=”Google1″ target=”_new”>Home</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google2″ target=”_new”>Consulting</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google3″ target=”_new”>Testing Services</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google4″ target=”_new”>Training</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google5″ target=”_new”>Affilliations</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google6″ target=”_new”>Careers</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google7″ target=”_new”>Blogs</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google8″ target=”_new”>About Us</a></li>&nbsp;|&nbsp;
    <li><a href=”http://www.google.com” title=”Google9″ target=”_new”>Contact Us</a></li>
</ul>
</div>
</body>
</html>

Once you ran the above code in browser, you should be able to see the below screenshot,

Home-PerformanceAlert(2)

Feel free to play around with some of the CSS Style in this piece of code so as to suit your requirements in terms of look and feel.

One of the things this exercise helped in understanding is that browsers execute CSS Styles sequentially for at least some of the tags with concept of first come first served basis.

Comments

HTML 5 Image Preview with File API’s

I have been working for sometime now on HTML5 with Image preview and upload functionality.Sometimes back I had tried to implement the image preview functionality on the client side using the JavaScript without HTML5 and had been having really hard time making the code work across all browser without tweaking the browser setting on the client side.I would say its impossible without a some kind of flash plugin or java applet to implement this functionality given that lot of browsers just blocks the script access to the input file src tag unless someone is extremely intelligent programmer.I had written about this earlier over here.Finally I gave up that approach and decided to have graceful fallback approach using both HTML5 and input file type by using the object detection feature of the browser.

HTML 5 has somewhat cool features when it comes to File API.With File API’s we can now have all the information as what is required to make the File preview functionality complete.Using HTML5 File Api,one can easily know the file name,file size and if required the file last modified date as well.Below is the rough code,which will give you some ideas as how to preview the image before uploading it in the server,

<!DOCTYPE HTML>
<html>
<head>
<meta charset=”utf-8″>
<script type=”text/javascript”src=”js/checkbrowser_01.js”>

</script>
<title>HTML 5 Image Preview</title>
</head>
<body>
<label>Upload your Image:</label>
<input name=”imguploader” type=”file” multiple=”" accept=”image/jpeg”

id=”idimgup” title=”Imageuploader” onChange=”previewimage1()”/>
<br></br>
<input name=”Submit” type=”button” class=”clbtnpreview” id=”idbtnpreview”

title=”Preview” onClick=”previewimage()” value=”Preview”/><br></br>
<div>
<img name=”DemoImage” src=”" id=”idimg” width=”400″ height=”400″

alt=”Demo Image” style=”background-color: #00FFFF”/>
</div>
</body>
</html>

In the above code,checkbrowser js file has below function which will take the image path and show it for preview by reading data as dataURL of the file reader interface.

imgreader = new FileReader();
imgreader.onload=function(Event){
document.getElementById(“idimg”).src = Event.target.result;
};
function previewimage1(){
if (document.getElementById(“idimgup”).files.length === 0)

{return; }
var File = document.getElementById(“idimgup”).files[0];
imgreader.readAsDataURL(File);
}

If you are using the F12 Developer tools of the browser ,we can clearly see the image path appended to the src of the image using the base 64 encoding.Using this approach one can easily preview the images on any HTML5 File API compliant browsers.

In addition to using FileReader interface for previewing images, we also have a choice of

using createObjectURL method for previewing the images.The code for windows create object URL looks like below,

<!DOCTYPE html>
<html>
<head>
<title>HTML 5 Image Preview Sample</title>
<meta http-equiv=”X-UA-Compatible” content=”IE=9″>
<style type=”text/css”>
span{
align:left;
}
</style>
</head>
<body>
<h1>HTML 5 Image Preview Sample</h1>
<input type=”file” id=”fileSelector” multiple accept=”image/*” />

<div id=”fileContentList” style=”list-style-type: inline-block;”><

br></br></div>

<!– This will be populated with <img> elements via JavaScript. –>
<script type=”text/javascript”>
var infomessage = [];
if (!document.getElementById(‘fileSelector’).files) {
message = ‘<p>The ‘ +
<a href=”http://dev.w3.org/2006/webapi/FileAPI/” target=”_blank”>

File API</a>s ‘ +
‘are not fully supported by this browser.</p>’ +
‘<p>Upgrade your browser to the latest version.</p>’;
document.querySelector(‘body’).innerHTML = infomessage;
}
else {
document.getElementById(‘fileSelector’).addEventListener(‘change’,

handleFileSelection, false);

// Add an onchange event listener for the <input id=”fileSelector”> element.
}
function handleFileSelection(evt) {

var files = evt.target.files; //The files selected by the user
if (!files) {
alert(“<p>At least one selected file is invalid – do not select any folders.</p);
return;
}
// The variable “files” is an array of file objects.
for (var i = 0, file; file = files[i]; i++) {
window.URL = window.URL || window.webkitURL;
var img_element = document.createElement(‘img’); // Select Image file only.
img_element.src = window.URL.createObjectURL(file);.
img_element.width = 400; // Make all images the same width.
img_element.height= 400;// Make all images the same height
img_element.style.verticalAlign = “middle”; //

img_element.style.margin = “4px 4px 4px 0″;

// The file URL is not needed once the file image has been fully loaded.
img_element.onload = function() {

window.URL.revokeObjectURL(this.src);

}
var span_element = document.createElement(‘span’);
span_element.innerHTML = file.name;
var li_element = document.createElement(‘li’);
li_element.style.display= “inline”;
li_element.appendChild(img_element);
li_element.appendChild(span_element);
document.getElementById(‘fileContentList’).appendChild(li_element);
} // for
} // handleFileSelection
</script>
</body>
</html>

If you are using createObjectURL method, then you need to make sure that you account for both windows and webkit objects by using the below code.

window.URL = window.URL || window.webkitURL;

However for some reasons,using the createObjectURL method was not working in Safari 5x and Opera 11x. With Opera 11.60/Safari 5.1(on windows 7) I can see in Dragon Fly/developer’s tools, that opera for some reasons do not identify the window.createURL as an Object and gives you type reference error.So this makes me believe that these 2 browsers has got somewhat partial support for file api though they both claim to support HTML5 file api’s completely.

There is one thing which I noticed while working with both the above codes, from the time I upload the image to the time browser displays the image for rendering, I can feel somewhat pause which was not the case earlier when I did not use HTML5 File API.Seems like I have a bias here.

Overall its good stuff and definitely a step which can enhance the speed of the web and websites.

Technorati Tags: HTML5,FileReader,createObjectURL,ImagePreview.

Comments

Browser’s Feature check for HTML 5 File API’s

Sometimes it becomes necessary that we check in the browser for its capability in supporting some features.While playing around with HTML5 File API’s I thought of  the below code for checking if the browser supports HTML5 File API.I have tested it in safari 5.1.2/IE 9.0 /FF 8.0 and Chrome 15.0x , it works perfectly and displays the information as what is required.

function checkforhtml5fileapi(){

  alert("Function works");

if (!document.getElementById('input file type element id').files) {

     alert(" Browser do not support HTML 5 File API Spec");

      }
          else {

     alert(" Browser supports HTML 5 File API Spec");

      }

     }

Comments

JSTL SQL Tags

I came across this JSTL SQL Tags while trying to find the way for fixing the session problem where in I was losing the session information for some reasons while displaying the result sets from servlets to JSP.JSTL tags were easy to learn and helped me in quickly bringing the page live.

JSTL SQL tags I believe is mostly related to interacting with database and provides a great interface from pulling the data out of database with minimal efforts.In case if you are in Netbeans its more of cakewalk,just pull and drop widgets from Netbeans palette and point it to the relevant data source.Database can be accessed both via JNDI Data source or by writing the connection strings in sql tags itself.We can just pull the data from the database and display it in with c out tag by iterating the result set. With SQL tags we can also set up the max result set size that can be retrieved in the database calls.

The first and foremost part to use JSTL tags is import JSTL tag library jars(Standard and JSTL.jars) and add it to the lib directory of the project and add the below line on the top of the page

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

Below is sample code for SQL Tags to access database directly with sql setdatasource tag

<sql:setDataSource var="databasename"
     url="jdbc:mysql://localhost:3306/databasename"
     driver="com.mysql.jdbc.Driver"
     user="databaseuserid" password="databasepassword"/>

In case if you have datasource defined in web xml file of the server, then its also quite easy to point the datasource with sql setDatasource tag,

<sql:setDataSource  dataSource="jdbc/databasename"/>

Once you have datasource configured correctly, you can fire the query to fetch your results with c tags of JSTL tag library you can iterate and display the datasets in the page.

<sql:query var="resultset" scope="page"  maxRows="100">
   SELECT xx from tablename where xx == y orderby z Desc;
</sql:query >

maxRows attribute in the above sql query will be fetch the  number of rows of data what you require to display in the page.Scope is what you set for depending on your requirements.It could be be either session/page/application etc.Once you have result sets ,you can display it in the page and rest is all formatting the page container elements in the HTML Tags.

I would like to  say that most experts in java web world will not prefer to directly interact with database from the web page but again if you have a small applications with known set of users, then probably I feel its alright to access the database from the page.

In case if you are developing with Netbeans, then I feel it makes your job quite easy and fast.

Comments

jQuery Clone() Method and Browser Crash.

For the application I am working on ,I am playing a lot of plain Javascript and jQuery Library whenever I find some time.Today I stumbled(after cool 4 hrs of trial and error ) upon the interesting behavior of jquery library which I was able to reproduce via a simple test case where in I was seeing that code was crashing my browser probably to missing HTML Tag and this behavior was since in Firefox 7.01, IE 9.0(hangs) ,Safari 5.1(hangs).Honestly I feel  below code goes into infinite loop and there is no checking happening in either on browser’s side or jquery side for completeness of tags.I feel that some thing is missing on the jquery side as it keeps appending the stuff to the body(I can see this clearly in Firefox).Unclosed UL tags are rendered perfectly by browsers as unordered lists though I would have expected that browsers should not have ignored the unclosed UL tags completely.Not sure if UL is one of the tags which as per HTML5 does not require a  end tag.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Simple Test Case</title>
</head>

<body>
<ul>
<li>Test1</li>
<li>Test2</li>
<li>Test3</li>
<li>Test4</li>
<li>Test5</li>
<li>Test6</li>

<script type="text/javascript"  src="js/jquery-1.6.4.js"></script>
<script>
jQuery('ul').clone().appendTo('body');
</script>
</body>
</html>

I feel either jquery is getting confused for not finding the end tag or something is wrong with clone method of jquery.Whatever it is, I feel it should not crash the browser nor it should consume the amount of memory the way it is consuming now in the above code.It definitely harms the user’s session terribly.

Comments

« Previous entries Next Page » Next Page »