SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Showing posts with label selenium webdriver. Show all posts
Showing posts with label selenium webdriver. Show all posts

Today we are going to see the installation of Python in Eclipse, so that we can use the python as a scripting language for writing the script for selenium WebDriver. Before that let’s see why python is preferred over java.

Preference Python over Java with Selenium  

There is an observation that most of the times python is used with selenium due to following points:
  1. Python is favored programming language as it runs faster than Java programs.
  2. Python uses indentation which is easy to use rather than using traditional braces to start and end block of code while programming.
  3. Python is easy to code due to dynamic typing as compared to static typing in java which can increase chances of syntactical error.
  4. Python is compact and easy to handle as compared to Java.

  • LinkedHashMap class is one of the class of map interface which extends HashMap class and implements Map interface.
  • It is combination of linked list and Hash table implementation of the Map interface and that's why it is called LinkedHashMap.
  • It is maintaining doubly-linked list insertion order in which keys were inserted into the map.
  • It allows to store null elements and optional Map operations are also available.
  • It is non synchronized implementation so if any thread modifies map structurally when map is accessed by multiple threads then it must be synchronized externally.

  • Is is pronounced as HashMap because It is hash table based implementation of map interface.
  • It extends AbstractMap class and implements Map interface.
  • It allows to store null key and null values.
  • It is non synchronized implementation so if multiple threads accessing it concurrently and any one of them modifies it then it must be synchronized externally.
  • It does not guarantee of maintaining the map order.

  • Java Map interface represents the mapping between unique keys to values.
  • Map can not hold duplicate values.
  • In Map interface, Each key can map at most one value.
  • Each Map interface provides three different collection views. Using which you can view map's content as a set of keys, collection of values and set of key-value mappings.
  • Map will helps you when you wants to search, update or delete elements based on it's key.
  • The map interface is implemented by different java classes like HashTable, HashMap and TreeMap.

  • TreeSet is class under Set interface of collection framework.
  • It implements NavigableSet interface which extends SortedSet interface.
  • Elements are ordered by a Comparator which is provided at set creation time or by natural ordering.
  • It maintains the ascending sorting order.
  • TreeSet is not synchronized so if multiple threads accessing it concurrently and any one modifies set entry then it must be synchronized externally.
  • Element's access and retrieval time is very fast from TreeSet so it will much useful when you wants to store large information in ascending order and retrieve any element quickly.
Java TreeSet Class hierarchy

  • SortedSet interface extends Set interface in collection framework of java.
  • As name suggest, It provides total ordering on elements of Set.
  • Set elements will be ordered using their natural ordering or using a comparator interface.
  • All the elements entries of SortedSet must implement Comparable interface.
  • All the elements of SortedSet must be comparable. So e1.compareTo(e2) must not throw ClassCastException.
  • In collection framework, TreeSet class is an implementation for the SortedSet interface.
Java SortedSet Interface hierarchy

It Is most Important to learn shortcuts of eclipse IDE If you wants to speed up Selenium WebDriver test creation and execution process because performing each and every actions In eclipse using just mouse Is time consuming. If you knows keyboard shortcut keys to perform regular actions In eclipse then It will be very easy for you to do It within one second.

  • HashSet is a class of collection framework which extends AbstractSet class and implements the Set interface.
  • HasSet doesn't guarantee that elements order will remain same over the time and returned in any random order.
  • HasSet doesn't allow duplicate values. If you try to insert duplicate, It will overwrite.
  • HasSet allows to store null values.
  • HasSet implementation is not synchronized.
Hashset hierarchy in Java Collection

  • LinkedHashSet Class extends extends HashSet class and Implements Set interface in collection interface hierarchy.
  • LinkedHashSet implementation differs from HashSet as it maintains doubly-linked list running through all of its entries.
  • It maintains element's entries in set as per it's insertion order. So it will allow you insertion order iteration over the set. So when you iterate over LinkedHashSet, In which order it will return elements? Answer is As per it's insertion order.
  • So you will get same copy of elements with the order how they inserted in set. 
  • LinkedHashSetis not synchronized.
LinkedHashSet Class hierarchy

  • Set is one of the collection framework interface which extends root Collections interface.
  • Set collection can not contain duplicate elements.
  • Set interface has all methods which are inherited from Collection interface with special restriction of not allowing duplicate elements.
  • If two Set interface contains same elements then both are equal.
  • Set interface is implemented by LinkedHashSet, HashSet classes and extended by SortedSet interface which is implemented by TreeSet.
Java Set Interface hierarchy

  • If you look at collection hierarchy, Queue extends collection interface.
  • Main purpose of collection is to hold the elements prior to processing.
  • Queue interface provides some additional operations like insertion, inspection and extraction besides collection interface operations.
  • All these three operations exist in 2 different forms. One return special value(null or false depending on the operation) if operation fails else throws an exception if operation fails.
  • Queue follows FIFO(first-in-first-out) so it will insert element at the end of the queue when you insert new element and element will be removed from the beginning of the queue when you remove element.
  • As Queue interface is sub type of collection interface, all methods of collection interface are also available in Queue interface.
Queue Interface hierarchy

  • Stack class in java is one of the collection interface class which is subclass of Vector class.
  • Stake class supports usual push and pop operations.
  • In contrast to queue, Stack class has last-in first-out(LIFO) data structure. So item which is inserted at top will be available first.
  • Stack class extends Vector class of List interface so it includes all methods of vector class and also it has it's own several methods to perform push and pop operations like looking top item from stack, removing top item from stack, push new item at top of stack, searching item from stack and check whether stack is empty.
java stack class example

  • Vector class in java implements List interface of collection framework.
  • Vector class is synchronized.
  • If you don't know size of array then you can use vector class as size of vector can grow and shrink as per adding and removing items.
  • As vector class is synchronized, It will give poor performance on add, delete, update and search operations.
  • Elements of vector can be accessed using it's integer index.
vector class hierarchy in java

  • LinkedList class extends AbstractList class.
  • LinkedList class implements List and Deque interfaces.
  • LinkedList class is using doubly linked list to store elements in list.
  • LinkedList can hold duplicate elements in list.
  • LinkedList is non synchronized.
  • Manipulation is faster in linkedlist as shifting is not required when new element is inserted or deleted from list.
  • You can use it as list, stack or queue as it implements List and Deque interfaces of collection framework.

Earlier have shared many tutorial examples on selenium IDE different commands and Its usage. You can view each of that example on Selenium IDE Tutorial. Still many peoples are using selenium IDE to automate their small web applications and sometimes they needs to perform compatibility testing In Google Chrome and IE browsers like submitting form, registration, login etc. activities.

We can perform these activities very easily In google chrome and IE browsers using Selenium WebDriver and you can view related tutorials link on Selenium Tutorial. Is It possible to run selenium IDE test In Google Chrome? Yes.. Follow steps given bellow to run selenium IDE test In google chrome browser.

Part 10

46 : What is Polymorphism?
Answer : Polymorphism is ability using which we can create reference variables or methods which behaves differently in different programmatic context. Best example of polymorphism is human. We behaves differently with different people in different environment. Our behavior will be different when we meet to boss and meet to friend. Read more on Polymorphism in java.

47 : What is the advantages of Polymorphism?
Answer : Main advantage of polymorphism is code reusabilty. You can dynamically supply different implementations through polymorphism. So it will reduce your work volume in terms of handling and distinguishing various objects.

Part 9

41 : In java, What is return type of main method?
Answer : Main method doesn't have any return type. It is void.

42 : Can We Overload main method in java?
Answer : Yes, Java class can have any number of main methods so it is possible to overload main method. But when you run program, It will not execute overloaded main method. Always It will execute only public static void main(String[] args) method.

Part 8

36 : What is the difference between the Constructor and Method?
Answer : Main difference between the Constructor and Method is as bellow.

Constructor :
  1. Name of the constructor must be same as class name.
  2. Constructor must not have any return type.
  3. It is used to initialize the state of an object.
  4. It is not possible to call constructor directly. Constructors called implicitly when the new keyword creates an object.
Method :
  1. Method name can be any.
  2. Method must have return type.
  3. It is used to expose behavior of an object.
  4. Methods can be called directly.
Read more on Constructor and Method.

Part 7

31 : What is default value of local variable.
Answer : There is not any default value of local variable. You must have to initialize it. View more details on local variables in java.

32 : Java support constructor inheritance?
Answer : No, Constructor inheritance is not supported in java. View more details on constructor in java.

Part 6

26 : What is local variable in java?
Answer : Local variable is declared inside method or constructor and it is limited for that method or constructor only. View more detail on local variable in java.

Local Variable Example :
public class JavaVariable {

 public void Calc() {
  // Local Variables.
  int sum;
  int item1 = 5;
  int item2 = 7;
  sum = item1 + item2;
  System.out.println("Sum is : " + sum);
 }

 public static void main(String args[]) {
  JavaVariable j = new JavaVariable();
  j.Calc();
 }
}