8 Ways to locate an element using Selenium - Java

For testing an application you need to first locate an element.There are many ways to select an element .

  • By ID. 
  • By name.
  • By class name.
  • By tag name.
  • By link text.
  • By partial link text.
  • By CSS.
  • By XPath.

Maximize Browser Window or Set Browser Size using Selenium Web driver - Java

                               Often we end up having to test the website on how it behaves in different screen resolutions.Here selenium provides us with two things one is to set the browser to a maximum size of the screen the browser is open on and the other is to provide the dimensions and set it.

Take Screenshot using Selenium Web Driver -Java

Most of the times you need to take a screenshot of a web page after you have performed a test on a page .This helps up if you have to send in a report where you have to include a screen shot in case a test case has failed.Selenium has TakeScreenshot class which will help you get the job done.

Basic Selenium Web Driver Program using Java

                           The most basic thing we have to do is to select an element and display the title of the article or a page.Let us display the title or contents of our website using a simple java program using selenium.
                           You need to know basics of  how to use eclipse and how to add libraries(jar) files to your eclipse Java project.

What is Selenium ?

Selenium is a set of software tools to perform automation tests on web applications.

                    Selenium was initially a JavaScript library developed by Jason Huggins in 2004 .It was able to interact with browser and automate the tasks on multiple browsers.This forms the Selenium core which is beneath Selenium RC and Selenium IDE. There were many limitations due to the restrictions of JavaScript in browsers.Later in 2004 Simon Stewart developed a tool that interacts directly with the browser.This project was called Web Driver.In 2008 they merged these two tools to make the current Selenium 2.0.