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

WebDriver interface has many different methods and get method is one of them. WebDriver interface is implemented by different browser classes like ChromeDriver, EdgeDriver, EventFiringWebDriver, FirefoxDriver, InternetExplorerDriver, OperaDriver, RemoteWebDriver and SafariDriver. So you can use get method to open any of these browser with given URL syntax.

get Method
  • Method Name : get
  • Method description : Using HTTP GET operation, It will load new web page in current web browser window. It will block all other operations until the browser load is completed. That means, Next syntax will be executed only after browser loaded completely with given URL.
  • Syntax : driver.get(String arg0)
  • Example : driver.get("");

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 ( "" )

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: - ), 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 The latest version can be downloaded from" 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.

Selenium webdriver is widely used open source automation testing tool in software testing industry which automates browsers. It is very compact object-oriented API which drives browsers natively on local or remote machines just like user interacts with browsers. If you look at the top trending automation testing tools, Selenium Webdriver is on top spot from last 10 to 12 years. It is being used by small scale companies to giant MNCs. As you know, Manual testing takes lots of time and efforts when your web application testing task is repetitive. Selenium automation will reduce your testing time and cost as you need to write selenium script just once and you can use those selenium automation testing scripts again and again whenever required. You can use those scripts mainly for regression testing of web application.

I am suggesting you to first Learn Selenium IDE From This Page and then start bellow given selenium tutorial. 
Selenium Tutorial

Selenium is free and supports many different languages like selenium Java, Python, Pearl, Ruby, PHP and C#. Selenium with java and selenium with python needs special mention here as both these languages are more popular than the other languages in selenium automation. To learn selenium with java, You should have java coding basics knowledge. If you are fresher then you should start java for beginners tutorial and then you can move to selenium tutorial. I have prepared very good set of java beginners tutorials for selenium learners which can help you to boost your java basics. Once you learn java basics, You can start with java advanced tutorials set.