SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

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

So in last article we have seen how to locate the WebElement using four locators and those are Name, Id, Partial Link Text and Link Text. Now in this article we are going to see the remaining four locators. Let’s start looking at them one by one.

Locating element By Xpath:
Xpath functions are very useful functions, it help to identify the Elements from its root node as well as from anywhere in the page. As HTML can be an execution of XML (XHTML), Selenium clients can use this amazing language to target WebElement in their web applications. XPath goes beyond (and additionally supporting) the straightforward techniques for situating by id or name attributes, and opens up a wide range of new conceivable outcomes, for example, finding the third checkbox on the page.

In this article, we are going to see how we can locate the web element to perform an action on it. Web element is the elements which are present on a webpage. Button, link, images, text boxes etc. this all are called as web element.

So why do we need to locate the WebElement? The simple answer for this question is, we need to locate the address of each WebElement on which we want to perform actions. Actions like entering the text, copying the text, pressing the buttons etc. actions 

By reading the above paragraph, we hope that you got an idea why we need to locate the WebElement. Now let’s see how we can locate the WebElement.

Today we are going to see the basic things which we are going to use while making the selenium WebDriver scripts using python language. So below is some short example which we are going to see the uses of each line statement

From selenium import webdriver

From selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox ()

driver.get ( "http://www.google.com" )

Assert "Python" in driver.title

Element = driver.find_element_by_name ( " address of webelement " )

Element.clear ()

Element.send_keys ( "content text" )

Element.send_keys ( Keys.RETURN )

Assert "No results found." not in driver.page_source

driver.close ()

The above script can be saved to a file (eg: - python_org_search.py ), then you can use it like this

Since last update of selenium 3, Most of the users(especially those who are new with selenium) are facing common issue with error "Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases" when try to execute test in firefox browser.

Configure Geckodriver In Selenium Test

  • Hashtable Class implements Map, Cloneable and Serializable interfaces and also extends Dictionary class.
  • It maps keys to values in table format. Every key is linked to it's value.
  • In Hashtable, any object which is non null will be used as a key or it's value.
  • Initial capacity and load factor are two parameters of Hashtable that affect its performance.
  • Meaning of capacity is the number of buckets in Hashtable and Meaning of initial capacity is number of buckets in Hashtable at the time of its creation.
  • Load factor is parameter which measure how much full Hashtable is and when to increase it's capacity automatically.
  • In order to successfully retrieve and store object in Hashtable, the object which is used as key must implement the equals and the hashCode methods.

  • ArrayDeque is one of the collection framework member which implements Deque, Cloneable and Serializable interfaces.
  • ArrayDeque provides Resizable-array implementation so it has no capacity restrictions and it will grow as per requirement.
  • In the absence of external synchronization, they are not thread safe. So they do not allow multiple threads to access it concurrently.
  • Also ArrayDequenot allow to store null elements.
  • ArrayDeque Class is faster than LinkedList when used as a queue and faster than Stack when used as a stack.
  • If ArrayDeque is modified after the iterator creation and if it is not modified by iterators own method then it will throw ConcurrentModificationException. So in concurrent modification, Iterator will fail.
Java ArrayDeque Class hierarchy

  • Deque is one of the collection interface which extends Queue interface.
  • Deque is linear collection which allow us to add and remove element from both ends of the queue.
  • It is "double ended queue" that's why it is called Deque and usually pronounced as "deck".
  • Deque has different methods to perform insert, delete and examine the element in queue.
  • Each of these methods have two different forms. One will throw an exception if it fails during operation and other will return a special value like null or false.
java deque interface

  • PriorityQueue Class is one of the collection framework class which implements Queue, Serializable, Iterable and Collection interfaces.
  • It is using natural ordering to order then elements of PriorityQueue.Or elements will be ordered based on Comparator provided at queue construction time depending on which constructor is used.
  • PriorityQueue is based on a priority heap. Heap is tree based data structure where all the nodes of tree are in a specific order. Please read about Heap to learn how it works.
  • PriorityQueue does not allow non-comparable objects and it may throw ClassCastException if you will try to do so.
  • PriorityQueue does not allow null elements as well.
  • PriorityQueue implementation is not synchronized. So multiple threads should not access it concurrently.
Java PriorityQueue Class

  • ArrayList class is sub class of collection interface which implements to List interface.
  • ArrayList class provides resizable-array so it can grow automatically as per requirement which resolves fixed Array limitation where you have to pre-define the size of array.
  • It can hold null elements too.
  • It is not synchronized implementation so if multiple threads accessing it concurrently and any one from them modifies the entry then it must be synchronized externally.
  • Also it can hold duplicate elements.
Java ArrayList Class hierarchy

What is Java Collections Framework?
Java Collections Framework is group of different interfaces, classes and algorithms. In simple word, Collection means single unit of objects and framework means good architecture. It is best architecture to store group of reusable objects and manipulate them. Collection framework has many different interfaces, their sub interfaces and classes, their classes and sub classes. All the interfaces and classes has different purpose. You can perform add, edit, delete, search, sort, etc operations on group of objects as per class's methods and implementation.

Java Collections Framework

Main Advantages Of Collection Framework
  • Main advantage of collection framework is it will reduces your programming efforts as there are ready made interfaces, classes and their methods which you can use directly in your program to perform operation on object collection. 
  • Collection is well structure framework so you code quality and speed will be increased.
  • Anyone can use collection very easily as it's interfaces, classes and methods very easy to understand and use.
Interfaces and Classes of Collection Framework
Collection, Set, List, Queue, Deque, SortedSet, Map and SortedMap are core interfaces of collection framework. Detailed description of collection framework's interfaces and it's classes is given on below given pages.


  • List interface in java is ordered collection so it can store elements in sequence.
  • List interface is sub interface and it extends to Collection interface.
  • List interface can hold duplicate elements so you can insert duplicate elements too.
  • You can access elements from list by integer index.
  • Collection framework has many interfaces in java and list interface is one of them.
  • List interface provides ListIterator to traverse through elements list in backward and forward directions.
List interface java

  • Collection is an interface in java.
  • Collection interface extends Iterable interface.
  • In hierarchy, Collection interface is root of List, Queue and Set interfaces.

Java Collection Interface

  • It represents unit of its elements. i.e. group of objects.
  • Some collections do not allow duplicate elements but some allows duplicate elements.
  • Collection interface is base on which collection framework is built.