Steps to configure Selenium WebDriver with java to develop test scripts

Pre-conditions: We need below files

Step 1: Download and Install JDK 8

Follow below URL

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Select Accept License Agreement radio button

Java SE Development Kit 8

Choose version to download: Windows 86 or x64 based on your OS (jdk-8-windows-i586.exe and jdk-8-windows-x64.exe)

  • wait until complete download.
  • copy downloaded file and paste in personal folder.
  • click on setup to start installation.
  • click on next until installation will go to end
  • click on close.
  • Restart Computer.

Note :

After completion of JDK installation tester can create environment variable for JAVA_HOME in your windows system by following below navigation.

  • Click on start
  • Right click on my computer
  • Click on properties
  • Click on Advanced system setting
  • Select Advanced tab
  • Click on Environment variable button
  • Go to user variables
  • click on New button
  • Type JAVA_HOME and provide path of JDK folder
  • click on ok

Follow below image

Environment variable button

  • Go to system variable
  • Select path
  • click on Edit button
  • Add path of JDK bin folder followed by semicolon(😉 at the end of existing path value
  • Click on ok
  • Click on ok

Follow below image

Environment variables

How to verify java successfully installed or not into your local system

  • Open the command prompt.
  • Run command “java -version”

 

It should show your installed java version detail as shown in above image. That means java is installed successfully into your local system and you are ready to use it.

Step 2: Download and launch Eclipse IDE

  1. IDE stands for Intigrated Development Environment. Eclipse Ide is useful to write our test scripts in java or java based tools like selenium.
  1. We need to follow below URL to download and launch Eclipse Ide

 

http://www.eclipse.org/downloads/packages/release/Mars/2

Eclipse Mars 2 Packages

 

Download the Eclipse Mars, you can choose version Windows 32 bit or 64 bit based on your OS

  • wait until complete download.
  • copy downloaded file and paste into personal folder and extract
  • click on Eclipse folder
  • Here click on ‘eclipse.exe’ file directly. Here no need to install eclipse into your local system.

Step 3: Download Selenium WebDriver Jar Files.

After completion of eclipse Ide launching with the creation of project, package, and class with main(), we need to download selenium webdriver jar file.

Follow the below steps :

  • Go to google search
  • Enter seleniumhq then search it
  • Click on first link(https://www.seleniumhq.org/download/)
  • Click on download
  • Scroll to Selenium Client & WebDriver Language Bindings
  • Click on download for java based selenium webdriver

Selenium Client & WebDriver Language Bindings

  • wait until complete download.
  • copy downloaded jar file and paste into personal folder and extract

Step 4: Associate selenium webdriver with eclipse Ide.

  • click on ‘eclipse.exe’ to start eclipse
  • First time when you start eclipse software application, it will ask you to select your workspace where your work will be stored as shown in bellow image.

Workspace Launcher

Choose a workspace folder name as D:\workspace and click on ok button .Here You can change the workspace location from ‘Switch Workspace’ under ‘file’ menu of eclipse.

Create new project

  • Go to File
  • New
  • Go to Java Project and give your project name ‘SeleniumProject’
  • Click on finish button.

Create new package

  • Right click on source folder(src)
  • New
  • Package
  • give the package name ‘SeleniumTests’
  • Click on finish button.

Create New Class

  • Right click on package ‘SeleniumTests’
  • New Class
  • give the class name ‘myTestLogin’
  • click on Finish button.

Add external jars for that project

  • Right click on project ‘SeleniumProject’
  • go to Java build path
  • configure build path
  • >select Libraries
  • Click on add external JARs button
  • Then go your jar file folder path location
  • select both .jar files from D:\selenium-java 3.12.0.
  • click on open button
  • Click on add external JARs button
  • Then go your jar file folder path location
  • select all .jar files from D:\selenium-java 3.11.0\libs
  • click on open button
  • click on ok button

Steps to Download and Install firebug Add-on.

Follow my below url to install Fire Bug

https://addons.mozilla.org/en-US/firefox/addon/firebug/

Click on Add to Firefox button

Click on Install button

After install FireBug then go to

Tools > Web Developer > Firebug > Open Firebug (or)you can use shortcut key ‘F12’

 

After open the firebug. Right-click on field or element in your application then click on inspect element with firebug option.

In html code take either id(or)name(or)className etc. from highlighted section.

See below image

Hospital Management System

Note: Here no need to restart your Firefox after installing Firebug Add-On

Steps to Download and Install firepath Add-on.

Follow my below url to install Firepath add-on

https://addons.mozilla.org/en-US/firefox/addon/firepath/

Click on Add to Firefox button

FirePath By pierre Tholence

Click on Install button

Click on Restart Now

After install firepath then go to

Tools > Web Developer > Firebug > Open Firebug (or)you can use shortcut key ‘F12’

You could find ‘FirePath’ as shown below image

 

Selenium WebDriver First Program :

TestSteps:

  • Open the firefox browser
  • Navigate the application url
  • Get the Title of the WebPage
  • Print the title of the webpage
  • Verify Title of the WebPage
  • Enter the username
  • Enter the password
  • Clicking On Login Button
  • Identify and get the Dashboard Text
  • Print the Dashboard Text
  • To verify whether the welcome page successfully opened or not
  • Clicking On Logout Button
  • Close the current Firefox Browser

Selenium Code :

package seleniumProject;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class SampleClass {

public static void main(String[] args) throws Interrupted Exception {

// open the firefox browser

WebDriver driver = new FirefoxDriver();

// navigate the application url

driver.get(“http://www.kosmiktechnologies.com/se leniumLiveProject/eKart/admin/”);

//Get the Title of the WebPage

String title=driver.getTitle();

//print the title of the webpage

System.out.println(title);

//Verify Title of the WebPage

if (title.equals(“Administration”))

{

System.out.println(“title verifiedsuccessfully”);

} else {

System.out.println(“title not verified successfully”);

}

// Enter the username

driver.findElement(By.name(“username”)).sendKeys (“Kadmin”);

// Enter the password

driver.findElement(By.name(“password”)).sendKeys (“K@admin”);

// Clicking On Login Button

driver.findElement(By.xpath(“//*[@id=’content’]/ div/div/div/div/div[2]/form/div[3]/button”)).cli ck();

// Identify and get the Dashboard Text

String text = driver.findElement(By.xpath(“//*[@id=’content’]/div[1]/div/h1”)).getText();

// Print the Dashboard Text

System.out.println(text);

// To verify whether the welcome page successfully opened or not

if (text.equals(“Dashboard”))

{

System.out.println(“Welcome pageverified successfully”);

} else {

System.out.println(“Welcome page not verified successfully”);

}

// Clicking On Logout Button

driver.findElement(By.xpath(“//*[@id=’header’]/u l/li[3]/a”)).click();

//Close the current Firefox Browser driver.close();

}

}

SELENIUM | BROWSER COMMANDS :

1.get() : This will be used to navigate the application url

Syntax : driver.get(“appURL”);

2.getTitle() : This will be used to get the title of the current Webpage.

Syntax : driver.getTitle();

3.findElement() : By using this we can identify single webelement On a webpage.

Ex: Button, checkbox, radio button etc.

Syntax : driver.findElement(By.Locator(“Locator-Value”));

4.findElements() : By using this we can identify list of webelements On a webpage.

Ex :

  1. Suppose if you want to identify dropdown values at a time then we use findElements method.
  2. Suppose if you want to identify list of frames in a webpage then we use findElements method.
  3. Suppose if you want to identify list of links in a webpage then we use findElements method.

Syntax :

List<WebElement> total_Links = driver.findElements(By.tagName(“a”));

5.sendKeys() : If you want to give the value to the input field(textbox,text area) then we use sendkeys method.

Syntax :

driver.findElement(By.locator(“locator-value”)).sendKeys(“text”);

6.getText() : If you want to get the particular text in a webpage then we use getText method.

Syntax :

String PageText=driver.findElement(By.Locator(“Locator-value”)).getText();

7.click() :Is there any click operation in your application then we use click().

Syntax :

driver.findElement(By.Locator(“Locator-value”)).click();

8.close() : This will be used to close the current browser window.

Syntax : driver.close();

Important Interview Questions :

1. How to Identify WebElement in selenium webdriver?

A )By using firebug and firepath we can Identify

WebElement.

2. Can we use firebug and firepath for chrome and Ie?

No,

1.Here firebug and firepath these two add-ons only for firefox.

2.Suppose if u want to identify the WebElement In chrome and ie here no need to install firebug and firepath. Becoz chrome and ie have its won developer tool to identify the web element.

3. What is the default package of selenium?

  1. org.openqa.selenium

4. What is the difference between findElement() and findElements()?Find ElementsfindElement() :

By using this we can identify single webelement On a webpage.

Ex : Button, checkbox,radio button etc.

Syntax : driver.findElement(By.Locator(“Locator-Value”));

TestSteps :

  • open the firefox browser
  • navigate the application url Enter the username
  • Close the current Firefox Browser

Selenium Program :

package seleniumProject;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class findElementMethod {

public static void main(String[] args) throws Interrupted Exception {

// open the firefox browser

WebDriver driver = new FirefoxDriver();

// navigate the application url

driver.get(“http://www.kosmiktechnologies.com/se leniumLiveProject/eKart/admin/”);

// Enter the username

driver.findElement(By.name(“username”)).sendKeys (“Kadmin”);

//Close the current Firefox Browser

driver.close()

}

}

findElements() : By using this we can identify list of webelements On a webpage.

Ex :

  • Suppose if you want to identify dropdown values at a time then we use findElements method.
  • Suppose if you want to identify list of frames in a webpage then we use findElements method.
  • Suppose if you want to identify list of links in a webpage then we use findElements method.

Syntax :

List<WebElement> total_Links = driver.findElements(By.tagName(“a”));

TestSteps :

  • open the firefox browser
  • navigate the application url
  • Identify all the links and store into total_Links variable Print the total Links on a webpage
  • Close the current Firefox Browser

Selenium Program :

package seleniumProject;

import java.util.List;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class findElementsMethod {

public static void main(String[] args) throws InterruptedException {

// open the firefox browser

WebDriver driver = new FirefoxDriver();

// navigate the application url

driver.get(“http://www.kosmiktechnologies.com/se leniumLiveProject/eKart/admin/”);

//Identify all the links and store into total_Links variable

List<WebElement> total_Links = driver.findElements(By.tagName(“a”));

//Print the total Links on a webpage

System.out.println(total_Links.size());

//Close the current Firefox Browser

driver.close();

}

}

5.How to verify particular text on a webpage using selenium webdriver?  (Or) How to verify successful message on a webpage using selenium webdriver?

TestSteps :

  • open the firefox browser
  • navigate the application url Enter the username
  • Enter the password
  • Clicking On Login Button
  • Identify and get the Dashboard Text Print the Dashboard Text
  • To verify whether the welcome page successfully opened or not Clicking On Logout Button
  • Close the current Firefox Browser

Selenium Program :

package seleniumProject;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class SampleClass {

public static void main(String[] args) throws Interrupted Exception {

// open the firefox browser

WebDriver driver = new FirefoxDriver();

// navigate the application url

driver.get(“http://www.kosmiktechnologies.com/se leniumLiveProject/eKart/admin/”);

// Enter the username

driver.findElement(By.name(“username”)).sendKeys (“Kadmin”);

// Enter the password

driver.findElement(By.name(“password”)).sendKeys (“K@admin”);

// Clicking On Login Button

driver.findElement(By.xpath(“//*[@id=’content’]/

div/div/div/div/div[2]/form/div[3]/button”)).click();

// Identify and get the Dashboard Text

String text =

driver.findElement(By.xpath(“//*[@id=’content’]/ div[1]/div/h1”)).getText();

// Print the Dashboard Text

System.out.println(text);

//To verify whether the welcome page successfully opened or not

if (text.equals(“Dashboard”))

{

System.out.println(“Text matched”);

} else {

System.out.println(“Text notmatched”);

}

// Clicking On Logout Button

driver.findElement(By.xpath(“//*[@id=’header’]/u l/li[3]/a”)).click();

//Close the current Firefox Browser

driver.close();

}

}

Control statements :

Syntax :

If(Actual_value.equals(Expected_value))

{

//Execute the code if condition is true

}else

{

//Execute the code if condition is false

}

Actual_value : Take the text from Testing Application.

Expected_value : client requirement

6.Difference between close() and quit() in selenium webdriver ?
Driver.close() :

By using this we can close the current browser window.

I.e Single window on which driver is having focus that will be closed only

Difference between close() and quit() in selenium webdriver

Driver.quit() : Every associated browser will be closed

I.e closed all the windows opened by the driver.

7. What is the purpose of public static void main() in java ?

public :

Since main() should be available to JVM. It should be declared as public.I f we don’t use main() as a public then it doesn’t make itself available to JVM and JVM cannot execute it.

Static :

We should be call the main() without creating an object, such methods are called static methods and we should be declared as static.

Void :

If main() it does not written any value then you have to put void(no value) before the main().

main():

If main() is not written in the java program then JVM will not execute the program.main() is the starting point for JVM to start execution of java.

What are the pre-requisites to run the selenium web driver?
  1. JDK 8
  1. Eclipse IDE
  1. Selenium JAR file
  1. Testing Application
  1. Browser (Firefox 53.0)
  1. Firebug
  1. Firepath

How to handle frame in selenium webdriver using java

Selenium Training in Hyderabad

kosmik technologies is the best institute for selenium training in Hyderabad. we offer classroom and selenium online training courses by certified faculty. Selenium is an open source tool for web application testing. This tool primarily developed in JavaScript and browser technologies and hence supports all major browsers on all the platforms. Selenium is one of the best tool available in the market for a web application.

AutoIT with Selenium | Selenium Coaching in Kukatpally

Selenium Coaching in Kukatpally

AutoIT with Selenium

 

Selenium is an open source tool that is design by automates web based applications. But to handle window GUI and non HTML popup in application. AutoIT is must as this Selenium doesn’t handle by window based activity.

AutoIt v3 is freeware. The combination of mouse movement, keystrokes and window control manipulation. To automate a task which is not possible by selenium web driver.

AutoIt Features

 

1) Easy to learn

2) Simulates keystrokes

3) Simulate mouse movements

4) Scripts can be compiling into standalone executable

5) Windows Management

6) Windows Controls

7) Detailed help file and large community

In short, any windows, mouse & keystrokes simulation. Which we cannot handle with Selenium that can handle with AutoIt. All we need to do is to use the script in Selenium which is generating with the help of AutoIt tool.

Moving ahead we will learn how to upload a file in selenium web driver using autoIT. Here we need three tools in to this.

  • Selenium Web driver
  • AutoIT editor and element identifier
  • The window that you want to automate

 

How to AutoIT download and install

 

1): Go to this link.

2): Dropdown on ‘Autoit’ and ‘Autoit Editor’ Hover.

 

2

 

 3) Click ‘AutoIT’ Downloads option.

 

3

 

 4): Download “Autoit” and then clicking on ‘Download Autoit’ button

 

4

 

5): Now download “Autoit editor” by clicking on ‘Downloads’ button.

 

5

 

 6): Click on the link as display below.

 

6

 

After download you will get two setup file as shown in below screen, first one is AutoIt version 3 setup. Second one is Scitautoit3.

 

7

 

 7): For Installing AutoIT-Click on both AutoIT setup one by one.

 

8): After successful installation – open up AutoIT Editor.

 

8

 

Go to ‘C: \Program Files

 

And click on ‘SciTE.exe’ file, the AutoIT editor opens as shown in below screen.

 

9

 

 9): Now opens element Identifier.

 

Go to ‘C: \Program Files (x86)\AutoIt3’

 

10

 

Selenium Coaching in Kukatpally

 

And click on ‘Au3Info.exe’ file, the element identifier opens as shown in below screen.

 

11

Selenium IDE Commands List

Selenium IDE Commands List-Hyderabad

The over all IDE script creation process classified into Three Steps.

1: Recording

2: Playing back

3: Saving

Step1: Recording

Selenium IDE supports to record user interactions with the browser. Thus the over all recorded actions are termed as Selenium IDE script.

Step2: Playing back

In this step, first we have to verify track stability and success rate. Then we can execute the recorded script in IDE.

Step2: Saving

Once we have recorded a stable script, we may want to save it for future runs and regressions.

Using Common features of Selenium IDE

Setting Execution speed

While testing web applications, we get across several scenarios where an action performed. Thus we must be having knowledge is enough while dealing such scenarios. So avoid failures while playing back these types of test scenarios.

Using Execute this command option

IDE let have executing a single test step within the entire test script. “Execute this command” option can be use at times when we want to debug of a particular test step.

Using Start point

To specify a start point within a test script to allows in IDE. The start point points to the test step from where we wish to start the test script execution. We customize the script to execute from a certain step.

Using Break point

User to specify break points within a test script to allow in IDE. The break points state Selenium IDE where to pause the test script. It can be use when we want to break the execution in small logical steps to execution trends.

Using Find Button

One of the most crucial features of IDE test scripts is to find and locate web elements within a web page. Web elements which have certain respect of thing associated with them. User can for challenging for making to identify a particular web element different. Selenium IDE provides Find button for the address of this issue.

Selenium IDE Commands

Types of Selenium IDE commands

Here three types of Selenium IDE commands. Each of the test steps in Selenium IDE falls extending any of the following categories.

  1. Actions
  2. Accessors
  3. Assertions

Actions

Actions commands are which interact with direct application either altering. Its state or by pouring some test data.

Accessors

Accessor’s commands are which allows user to store certain values to user defined variable. These keep values can be later on used to create assertions and verifications.

Assertion

Assertions are like to Accessors as they can’t interact with the application. Assertions are use to verify the present state of the application with a regard state.

Forms of Assertions:

  1. Assert:This command makes sure that the test executionis end in case of failure.
  2. Verify: This command lets the IDEto supporton with the test script execution even if the verification is fails.
  3. Wait For:This command waits for an exact condition to arrangebefore executing the next test step.

These conditions are like page to be load, element to be present extending

Selenium Automation Testing Scope?

 

Selenium Automation Testing

Selenium Automation Testing Scope:

Future of software testing is always good. It will always need. Customer will never accept the product without software test. Testing is always good as it gives everyone a confidence of the work . It’s always good to add more processes while the test, so that should not think testing is an easy job.

Testing tools are divided into two tools that are Manual and Automation. Again Automation is divided into two tools such as QTP and Selenium.

Selenium is good for the future scope to compare to the QTP. These both tools are awesome. But, In Selenium suite we have the IDE Tool, Web driver, RC, and Grid. As a beginner, we use to learn the concept of any one language like Core Java, Javascript, C #… Etc… Selenium is easy to learn to compare to QTP. You must know the “How to use the tool” and VB Script Language before you learn the QTP. It is the most important to write the test scripts on the QTP Tool.

In Selenium:

Which is a support Web-based ?

No feature such as Object Repository/Recovery Scenario.

No IDE, so the script development won’t be as fast as QTP.
There is no default test report generation. For parameterization, the user has to rely on the language.

Selenium supports Linux, Windows, and Mac.

It supports all latest browsers like Google chrome, Firefox, Internet explorer, Opera, and Safari.

Selenium supports Functional and testing and finally It is more consistency, flexible and Extendable.

So, nowadays selenium has a lot of importance on the market. Selenium is free to use. Selenium gives lots of opportunities and it will be easy to approve by the company.

There is a huge community with a huge amount of people provide the support.

They are people who are using the tools, so they will provide the most practical suggestions.

This clear depends on the usage patterns of Selenium and QTP in industry. Selenium users have a good opportunity.

Selenium code base is open source to any particular firm.

Many new things and compatibility features added.

The above reasons Selenium now a day’s pickup a lot of Important on the Markets.

Online Selenium Training in Hyderabad

Online Selenium Training in Hyderabad

Course name:  Selenium

Faculty : Highly qualified and experience

About Online Selenium Training in Hyderabad

Kosmik is a Best Institute for Online Selenium Training in Hyderabad. we proud to say kosmik is one of the Best Online Selenium Training Institute in Hyderabad. we are providing Online Selenium Training in Hyderabad with Live projects. Selenium Training in Hyderabad faculty is Highly qualified and experienced. kosmik Designed Online Selenium training course in Hyderabad as per the Latest trend. kosmik provides 24*7 days Online support for the students. Our faculty is going to cover all concepts in depth online selenium training in Hyderabad. kosmik is right choice for Online Selenium Training in Hyderabad, India.

Highlights of the Selenium Training :

we provides course material with real time scenarios.
we are providing classes with real time experienced faculty.
we will conduct demo sessions at students flexible timings.
we will give 365 days technical support.
Every concept will be covered with real time solution.
we are also having weekend and fast track batches.
we are providing job oriented training.
we are giving placement support for the students.

Online Selenium Training in Hyderabad Course Content :

Introduction and Overview to Selenium Training

Introduction to Automation testing
Why and When it comes into picture
supporting browsers and platforms of selenium
Basic concepts of Java
Uses of Automation Testing
Environment needs for selenium
Difference between selenium and QTP
Features of Selenium

Web Driver

web driver for selenium
web driver v/s RC
Accessing multiple browsers using web driver
Internet Explorer
Mozilla Firefox
Google chrome
Installation and Configuring Eclipse for web driver
Constructing X path for web element using Firebug-Fire Path methods.
starts with
Parent
Ancestor
Following and preceding sibling
Normalize space
sub string
Handling web elements using web driver
Handling Attributes of developer tools of Internet explorer

Form Controls

Accessing Input box
Accessing combo Boxes using select and List
Accessing Check Box
Accessing Links

Parameterization

Accessing rows and columns of Excel sheet
Parameterization of test data using MS Excel sheet

Selenium Training in Hyderabad, Classroom & Online Training

About Selenium Training in Hyderabad

Kosmik Technologies providing best Selenium Training in Hyderabad, we are offering Classroom and Online Selenium training by real time experienced faculty. Our faculty is Certified, dedicated and Highly Qualified. Kosmik Technologies provide 24/7 days online support for the students. Our selenium Training course content designed as per the latest trend. We are offering job oriented selenium Training. We are covering each & every topic in detail and real time projects. Kosmik Technologies is the best institute for Selenium Training in Hyderabad.

Course Highlights

selenium testing tool introduction
selenium components and architecture
selenium vs other automation tools
selenium features advantages
Testing framework in selenium
eclipse framework

Selenium Architecture:

selenium RC and webdriver architecture
webdriver vs selenium RC
advantages of webdriver for selenium ide

Locator techniques in selenium:

Introduction Locator concept
About different locator techniques
selenium XPath locator contains text

Selenium IDE:

Download & Installation
record and playback in selenium
how to modify script using IDE
convert selenium ide to selenium RC
validate the locator using IDE

Selenium Setup:

step by step Explanation for setup
integration of selenium with eclipse

Selenium RC:

selenium server start
test annotation in selenium
basic selenium script

Webdriver in Selenium:

selenium webdriver setup
webdriver commands with examples
event handling in different browsers
webdriver methods in selenium
selenium webdriver programming
RC commands from webdriver
migrating selenium rc to webdriver
project structure organization

Testing Framework in Selenium:

selenium test framework design
testing annotations in selenium
testing configuration
suite execution from command prompt
testing suite parallel execution
report generation in selenium webdriver
assertion selenium
selenium verification errors
listeners concept in selenium
Preparing customized report using selenium & Java

Auto IT in selenium:

Autoit tool in selenium webdriver
create AutoIt script
au3 to Exe converter
Autoit script in selenium webdriver

Selenium Grid:

Introduction
selenium grid setup
selenium grid parallel execution
simple script execute commands