Friday, November 9, 2012

Getting the Big picture

I am happy to share a nice story told by a senior people in our company.

The story starts like this, a curious journalist wandering along the roadside. He saw some people working in a construction site. He went to some people and asked a question.

The question is "What you are working at?"

First person said that he was laying bricks.

Second one said that he was constructing a wall.

Third one said "I am building my nation".

The journalist wondered and asked him to explain. The worker said, "We are constructing a bridge and using the bridge the two ends will get better connectivity thereby commerce will improve and finally my nation's economic growth will increase."

Among the three workers the third one gave a big picture (goal) of what he is doing.

Similarly we should be aware of "What we are really doing?".

Sunday, July 22, 2012

Simple AJAX demo

In this article, I would like to give a quick demo of how to code a basic AJAX function.

function ajaxfunction(arguments_if_any){
    if (typeof XMLHttpRequest != "undefined"){
        xmlHttp = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (xmlHttp == null){
        alert ("Browser does not support XMLHTTP Request");
 return false;
    }

    var url;
     
    url = "/application-name/any-serverside-program";
    url += "?name="+value;
        
    xmlHttp.onreadystatechange = callback-function-name;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    return true;    

}

function callback-function-name(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        /* Stuff to do */
 document.getElementById('id').innerHTML = xmlHttp.responseText;
    }
}


Explanation
  1. First the function 'ajaxfunction' is called during a particular event like clicking a div tag or others.
  2. It checks whether the browser is able to send and receive a XMLHttpRequest object through which asynchronous request and response is achieved.
  3. If the support is available, an asynchronous request is made to a server side script (php/JSP) and once the response is received a 'callbackfunction' is executed.
  4. The third parameter in the open() method, in this case true implies that async is turned ON.
  5. The send() method is useful if we are using POST method - we can send large information using it. Example:- xmlHttp.send("fname=Athi&lname=Ruban");
  6. To assign a stream of HTML from a server output to a div tag we use InnerHtml property.

Monday, January 23, 2012

Add comments using VIM editor

Very Useful VIM editor trick ,,,,,,,,,,,,,,,,


To add comments easily to any code


First Press Ctrl+v to start the visual mode from a particular location then select the needed characters using arrow button

Second Press I to enter into a special insert mode to input characters like '//' and Press Esc.


Now the inserted character will appear in all the selected lines.


To remove this first character again select the needed characters and Press 'd' to remove it.

Another form to add words at the end of each selected lines Press 'A' append, then add words and press Esc

If we press $ the whole line will be selected.

Some more short-cut keys in command mode(Press Esc).
yy - copy
p - paste
d - to cut

Friday, January 6, 2012

GUI Testing using UISpec4J api

I would like to share some information regarding how to use UISpec4J for GUI Testing. This post will be edited with more information as soon as I gain experience in that.

First we have to create a setup method like this inside the subclass we extended from UISpecTestCase

protected void setUp() throws Exception {
 

super.setUp();
UISpec4J.setWindowInterceptionTimeLimit(TIMELIMITININT);

setAdapter(new MainClassAdapter(YOURMAINCLASS.class));

Window window = getMainWindow();
 

// Get references to UI elements 
 

}

While getting references to other elements, we have to make sure that it is easily accessible to UISpec4J. For that developers, should use setName() method for the UI elements like button, text box, panel, etc .......

If the element is not directly accessible (ie. nested inside many panels). We have to use the panel1 = window.getPanel("PANELNAME") method to get a reference.

So using the panel2 = panel1.getPanel("PANELNAME") method we can easily
go to the particular panel in the application window.

Note :- Before making assertions we have to call the UISpec4J.setAssertionTimeLimit(int ms) to give a delay before starting the assertion.

To intercept a modal dialog box, we have to use like this,
UISpec4J.setWindowInterceptionTimeLimit(12000);
WindowInterceptor
.init(ANY TRIGGER EVENT)
.process(new WindowHandler("Main Window") {
public Trigger process(Window window) {
// Now you can use the window to access the elements in the modal dialog box
return window.getButton("OK").triggerClick();

}
})
.run();
If anything wrong, inform me. :)