Monday, August 20, 2012

Adding new method to Selenium User Extensions

Below steps are required for adding the method to user extension js file. User can use the following method "getCurrentTime" as selenium function for returning the currentTime.


Add following code to user extensions js file

Method is getCurrentTime and it returns the currenTime\

// Return the currentTime in the format HH:MM:SS

Selenium.prototype.getCurrentTime = function(currentTime){

        var d = new Date();
        var curr_hour = d.getHours();
        var curr_min = d.getMinutes();
        var curr_sec = d.getSeconds();

        currentTime = curr_hour+':' + curr_min + ':'+ curr_sec;
        return currentTime;

};

Linked List Operations in Java Using LinkedList Utility Class


package com.test;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class LinkedListFunctions {

public static void main(String args[]){
LinkedList list=new LinkedList();

//Adding elements in Linked List
list.add(12);
list.add(17);
list.add(4);
list.add(45);
list.add(3);

// Printing elements in Linked List;
System.out.println(list);

//Printing the elements using iterator
Iterator itr=list.iterator();
while(itr.hasNext())
System.out.println(itr.next());

//Adding elements First and Last
list.addFirst(1);
System.out.println(list);

list.addLast(99);
System.out.println(list);

System.out.println("Get the size of List"+list.size());

//Sort the list using Collections Sort
Collections.sort(list);
System.out.println(list);

//Get the sublist from list
System.out.println(list.subList(2, 4));

//Stack Operations Using Linked List
System.out.println(list.peek());
System.out.println(list.poll());
System.out.println(list.pop());

}
}