MavenPlugin Download

Step-1
Open Google
Search for Maven Plugin Eclipse
Click on link “Eclipse.org/m2e/”

1

Step-2
Copy Below Links from M2Eclicpse page
“http://download.eclipse.org/technology/m2e/release”

2

Step-3
Open Eclipse —-Goto Help menu
Select “Install New Software”

3

Step-4
Paste the copied url in the text box “work with”
Click on add button

4

Step-5
Enter a name in the ”Add Repository” window that opens
Click ok button

5

Step-6
Check the checkbox “Maven Integration for Eclipse”
Click next button

6

Step-7
Click finish button in the next window
You will see a message showing the installation in being done

7

Step-8
Once the installation is done, you will see a message box asking if you want to restart the eclipse or not
Click yes button

8

Step-9
In the package explorer, right click choose new -> Project

9

Step-10
In the select wizard window, choose Maven and expand the folder
Select Maven Project
Click Next button


Step-11
Click Next button in the New Maven Project window

11

Step-12
Choose the option shown in the window for the Group id, Artifact id and Version
Click next button

12

Step-13
Enter some value in the Group ID, Artifact id and choose the version
Click on finish button

13

Step-14
Go to project explorer and you will see a project created with the Artifact id name entered in the step 13
Double click on the pom.xml file at the end of the project
Click last tab pom.xml in the right side

14

Step-15
Go to mvnrepository.com using google

15

Step-16
Search for selenium java
Click on the link selenium-java

16

Step-17
Click on the latest release jar version

17

Step-18
In the window where we have download jar link, you have a tab “Maven” at the bottom of the page
Copy the “dependency” tag values

18

Step-19
Paste dependency tag values in the pom.xml file under “dependencies” tag
Right click on the project, choose run as maven build…

19

Step-20
Right click on the project, choose run as maven build…

20

Step-21
In the next window, enter “mvn compile” in the command text box and run

21

Step-22
You will observe that under the project created, in the “maven dependencies” some jar files will be seen without we configuring them
These are the same files we added with “dependency” tag values in pom.xml

22

Step-23
Follow steps 15 to 20 for different jar files we need to configure into the project like junit, poi, testing.jar, etc.,

23

Maven Intorduction

Apache Maven Is Powerful Java project management and build management tool. That means we can manage java project builds very easily using maven. Maven can helps you to minimize your project and build management time and efforts.
Why To Use Maven In Selenium Project?
As Maven Is build management tool, It will helps you to manage your selenium project’s build easily. It Is build management tool and It will manage your selenium test project’s build compilation, documentation and other related project tasks It self. It will helps you to create right project structure, add and manage jar files In project’s build path etc..
Maven uses POM.xml configuration file which kept all project configuration related Information. For selenium, You need to provide selenium webdriver version related Information In POM.xml file and then It will download all required jar files automatically and store It In local repository called m2. Later on If you wants to change version of selenium webdriver then you need to modify version In POM.xml file only. Then maven will download new version jar files automatically and store In local repository. That means If you upgrade any dependency’s version In POM.xml file, First It will check that version’s jar files are available or not In local repository. If available then fine else It will download them from maven central repository.

DOWNLOAD Apachi POI

Apache provides a library POI using which read and write of an excel can be performed in Selenium WebDriver. Using it the read and write operation of both xls and xlsx file formats can be done. So first you need to download the Apache POI and configure it (jar files) in your eclipse. Implement the following steps to read an excel file
Step-1 :-
• Open Google
• Search for “Apache POI”
• Click on the Link “Apachi POI-Download Release Artifacts”
download-apachi-poi1

Step-2 :-
• Click on the Link “POI-bin 3.14 zip”
download-apachi-poi2

Step-3 :-
• Click on the link “http://www.apache.org/dist/poi/release/bin/poi-bin-3.14.zip”

download-apachi-poi3
Step-4 :-
• After Downloading Extract ZIP file
• Open the Folder Add Below Shown Jar files into Eclipse Project as Mentioned In the Next step
download-apachi-poi4

Step-5 :-
• Open Eclipse
• Go to Project Right Click Choose BuildPath Option
• Again choose Configure Build Path in The SubMenu

download-apachi-poi5

Step-6 :-
• In the Window That Opens Go to Libraries tab
• Click on Add External Jar file button
download-apachi-poi6
Step-7 :-
• Browse and Choose Required Jar files To be Added to the Project
• As mentioned in the Step-4
download-apachi-poi7
Step-8 :-
• Click on Apply
• Click on Ok

download-apachi-poi8

Step-9 :-
• Once All Jar files Are added U will see those things under the Reference Libraries file
download-apachi-poi9

Apache POI Intorduction

Apache POI is a popular API that allows programmers to create, modify, and display MS Office files using Java programs. It is an open source library developed and distributed by Apache Software Foundation to design or modify Microsoft Office files using Java program. It contains classes and methods to decode the user input data or a file into MS Office documents
Using POI, one should be able to perform create, modify and display/read operations on following file formats

Apache-POI-Intorduction
JXL
JXL is a third-party framework designed for Selenium that supports data driven automation on web browsers (auto-update of data on web browsers). However it is also used as a common support library for JExcel API because it has basic features to create, read, and write spreadsheets. The basic features are as follows:
• Generate Excel files
• Import data from workbooks and spreadsheets
• Obtain the total number of rows and columns
Note : JXL supports only .xls file format and it cannot handle large data volume.

TestNg Installation

Installing TestNG in Eclipse
—————————————–
• Launch Eclipse.
• On the menu bar, click Help.
• Choose the “Install New Software…” option.

Step-1 :-
TestNg-Installation1

Step-2 :-
• Open Google
• Search for “Download TestNG”
• Click On the Link

TestNg-Installation2

Step-3 :-
Copy the selected url part (should not even include the space or dot) – http://beust.com/eclipse

TestNg-Installation3
Step-4 :-
Paste the copied url in the “work with” bar and click on the add button
TestNg-Installation4

Step-5 :-
Enter a name of your choice like “TestNg” and click ok button

TestNg-Installation5
Step-6 :-
A check box with the name TestNG will appear as shown in the screenshot. Click next button to take it the next screen
TestNg-Installation6

Step-7 :-
Click next button in the next screen again

TestNg-Installation7

Step-8 :-
In the next page, you will see a accept/ do not accept agreement options. Choose “I accept” and click Finish button
TestNg-Installation8

Step-9 :-
In a few seconds, TestNG gets installed into your Eclipse

TestNg-Installation9
TestNg-Installation10
Step-10 :-
• To verify if it is successfully installed or not, go to “Window” menu.
• choose “show view” option
• select “Other”
TestNg-Installation11

Step-11 :-
In the window that appears, you should be able to see TestNG as an option

TestNg-Installation12

TestNG Intorduction

TestNG(Next Generation) is an open source testing framework written in Java and inspired from JUnit and NUnit, it is not only inherited existing functionality from Junit as well as introducing some new innovative functionality that make it powerful, easy to use, reliable, maintainable and testable codes.

.TestNG means Next Generation. TestNG is similar to JUnit but it is much more powerful than JUnit but still it’s inspired by JUnit. It is designed to be better than JUnit, especially when testing integrated classes. Pay special thanks to Cedric Beust who is the creator of TestNG.

TestNG eliminates most of the limitations of the older framework and gives the developer the ability to write more flexible and powerful tests with help of easy annotations, grouping, sequencing & parametrizing.

TestNG
Benefits of TestNG

  • HTML reports of Execution.
  • Logs
  • Support for parameters
  • Support for multi-threaded testing
  • Data Provider (Data driven Testing)
  • Supported by a variety of tools and plug-ins (Eclipse, Maven, etc…).
  • Listeners

 

 

Annotations

@Test

This annotation method will execute method as a test method or part of your test.

@BeforeMethod

This annotation method will execute before each test method.

@AfterMethod

The annotated method will be executed after each test method

@BeforeClass

This annotation method will execute before the first test method in the current class is invoked

@AfterClass

This annotation method will execute after all the test methods in the current class have been executed.

@BeforeTest

This annotation method will execute before any test method belonging to the classes inside the Test tag is executed

@AfterTest

This annotation method will execute after all the test methods belonging to the classes inside the Test tag have executed

@BeforeSuite

This annotation method will execute before all tests in this suite

@AfterSuite

This annotation method will execute after all tests in this suite

@DataProvider

This method is used in supplying data for a test method @BeforeGroups

@BeforeGroups

@BeforeGroups annotated method will run before the first test run of that specific group.

@AfterGroups

@AfterGroups annotated method will run after all test methods of that group completes its execution.

@Parameters

When you wants to pass parameters in your test methods, you need to use @Parameters annotation.

@Factory

When you wants to execute specific group of test cases with different values, you need to use @Factory annotation. An array of class objects is returned by @Factory annotated method and those TestNG will those objects as test classes.

@Listeners

@Listeners are used to with test class. It is helpful for logging purpose.

 

Perform Operations on WebElements

      Perform Operations on WebElements

 click()

Purpose: This is used to click on webelements like link,button,radio group,checkbox,images…etc.

sendKeys()

Purpose: This is used to sending inputs into text fields and text areas.And also used to select value from the drop down box.

clear()

Purpose: This is used to clear the input from existing data.

getText()

Purpose: This is used to capture text of the webElement.

 getTagName()

Purpose: This is used to capture html tag of the webElement.

getLocation()

Purpose: This is used to capture X and Y co-ordinates of webelement in the application.

isSelected()

Purpose: This is used to check,is the check-box is currently checked or unchecked to checked Radio buttons are selected or not.

 isDisplayed()

Purpose: This is a boolean condition.It is used to either an element is visible or not.

If an element is displayed it gives true and an element is not displayed it gives false.

isEnabled()

Purpose: This is a boolean condition.It is used to either an element is enable or not.

If an element is enable it gives true and an element is disable it gives false.

getAttribute ()

Purpose: This is used to capture the attributes which are present in web applications.

Webdriver Methods

get()

Purpose: Its Opens Specified Url in the Browser Window

//Launch Browser

System.setProperty(“webdriver.chrome.driver”,”D:\\Onlineqaclasses\\chromedriver_win32\\chromedriver.exe”);

//ChromeDriver driver=new ChromeDriver();

System.setProperty(“webdriver.ie.driver”,”D:\\Onlineqaclasses\\IEDriverServer_Win32_2.53.0\\IEDriverServer.exe”);

InternetExplorerDriver driver=new InternetExplorerDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

 getCurrentUrl()

Purpose: Its Returns title of the Browser

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

//Using getCurrentUrl()

String url=driver.getCurrentUrl();

System.out.println(“Current page url is—> “+url);

getTitle()

Purpose: Gets the title of the current web page.

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

//Using getCurrentUrl()

String title=driver.getTitle();

System.out.println(“Current page url is—> “+title);

getPageSource()

Purpose: Get the source of the currently loaded page.

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

 

//Using getPageSource()

String pagesource=driver.getPageSource();

 

System.out.println(pagesource);

 

 findElement()

Purpose: Find the first WebElement using the given method.

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

//Using findElement()

WebElement gmaillink=driver.findElement(By.className(“gb_P”));

//Getting name of link

System.out.println(“result element name :”+gmaillink.getText());

 

findElements()

Purpose: Find all elements within the current page using the given mechanism.

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

//Using findElements()

List<WebElement> links=driver.findElements(By.TagName(“a”));

//Counting no of links in result page

System.out.println(“Number of Links in current page :”+links.size());

 

 

close()

Purpose: Close the current window, if there are multiple windows, it will close the current window which is active and quits the browser if it’s the last window opened currently.

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

//Using close()

driver.close();

 

 quit()

Purpose: Quits this driver instance, closing every associated window which is opened.

//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://www.onlineqaclasses.com”);

//Using quit()

driver.quit();

 

getWindowHandle()
Purpose: Whenever the web driver launches the browser it assigns the unique id to that browser which is called as window handler. This can be captured through the method.

Syntax: driver.getWindowhandle()

 

getWindowHandles()

Purpose:: Whenever multiple windows are opened by webdriver and we want to capture all their ids. We use this method.

Syntax: getWindowHandles()

 

switchTo():-

Purpose:used to switch from one window to another window (or) window to a frame (or)  frame to a window (or) window to an alert

Syntax: driver.switchTo().window();

driver.switchTo().frame();

driver.switchTo().alert();

 

 

navigate()
Purpose: An abstraction allowing the driver to access the browser’s history and to navigate to a given URL.&Refresh page
//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://gmail.com”);

//navigate to page

driver.navigate().to(“http://onlineqaclasses.com “);

//navigate to back

driver.navigate().back();

//navigate to forward

driver.navigate().forward();

//navigate to refresh page

driver.navigate().refresh();

 

 

manage()

 

Purpose: This is used to perform various activities like maximize the size of the window, Cpture the information about the cookies, setting implicit wait etc.
//Launch Browser

FirefoxDriver driver=new FirefoxDriver();

//Using get()

driver.get(“http://gmail.com”);

//to maximize window

driver.manage().window().maximize();

 

 

 

 

What is Webdriver

Selenium WebDriver Is open source software testing tool which supports many different browsers. It Is also supporting many different software programming languages like Python, Ruby, C#, Java, PHP and Perl so that you can create your test cases using your preferred language. Current days, Most popular language Is Java to prepare your software application automation test cases with selenium webdriver.

 

Advantages of Selenium WebDriver:

  1. Improved features & functionality which were not supported in the Selenium 1.0.
  2. No need to start server prior to start executing scripts.
  3. Added advantage to support for iPhone and Android testing
  4. Similar to QTP, It allows you to extract the objects in bulk. In RC this is big pain to extracting the objects.
  5. It supports features like Page navigation, Drag-and-drop and AJAX-based UI elements.
  6. Using WebDriver can easily find the coordinates of any object.
  7. WebDriver is open source & it allows you to easily integrate with testing framework like JUnit or TestNG.
  8. It allows you to simulate the mouse movements.
  9. It provides the improved reliability between browsers.
  10. A most awaiting feature added in WebDriver is “Implementation of listeners”.
  11. For web application testing, it provides standard programming interface.
  12. It allows you to simulate keyboard key press events using different classes.
  13. You have classes in Webdriver which help you to simulate key press events of keyboard.
  14. It allows you to simulate the clicking of browser front and back button.

 

 

 

Download Eclipse and Create Project,Package,class

Step-1
Open Google Search For “Download Eclipse”
Click on “http://eclipse.org/Downloads/”
download-eclipse1
Step-2
• If your System is 32 bit click on 32 bit otherwise click on 64 bit
download-eclipse2
Step-3
Click on “Download” Latest version of Eclipse

download-eclipse3
Step-4
“eclipse-jee-mars-1 win32.zip” Zip file can be seen once downloaded, in the downloads folder
download-eclipse4
Step-5
Select Zip file —Right Click, select —Extract Files
download-eclipse5
Step-6
Open Extracted Eclipse folder
we can find a sub-folder “Eclipse” In this folder
download-eclipse6
Step-7
Open the Eclipse folder
Click on Eclipse.exe Blue color icon
download-eclipse7
Step-8
Browse and select Workspace folder to save Programs
download-eclipse8
Step-9
Click on Workbench Icon
download-eclipse9
Step-10
To Create Project
In Project Explorer — Go to –File—New—Select Project
download-eclipse10
Step-11
Select Java Folder
Select Java project under Java folder
Click on Next Button
download-eclipse11
Step-12
Enter Project name click on Next Button
download-eclipse12
Step-13
Expand Project Folder
And u will see 2 sub folders—SRC-and –JRE Folders
download-eclipse13
Step-14
Select Src Folder—Rightclick –New—package
download-eclipse14
Step-15
Enter Package name—click on Finish
download-eclipse15
Step-16
Select package folder – RightClick—>New—>Class
download-eclipse16
Step-17
Enter Class name
Select First Checkbox mentioning “public static void main”
Click on next button
download-eclipse17

Step-18
You will now see the class file created under the package in the package explorer
In the right side pane, see the code for the class

download-eclipse18