It Is an Open Source Functional Automation Tool

It Is an Open Source Functional Automation Tool

SELENIUM

It is an open source functional automation tool.

Automation:-

The process of converting the manual test cases to test scripts with the help of some automation tool is known as automation. These scripts can be executed on the targeted application when ever needed.

Advantages:-

  • We can save the test execution time( regression time). On and average to save around 50-60% of the test execution time.
  • We can reduce CTC(Cost To The Company).
  • The test scripts are repeatable on multiple builds.
  • We can maintain accuracy by executing the same scripts in the same manner.
  • Bugs can be identified.
  • The tool will provide the test report to analyse the bugs and we can ensure for quality.

C Users atish Desktop testing1 png

What is the difference between selenium and QTP? (Or) Why you have selenium for your project?

Selenium features QTP features

  • Open source Commercial tool & Costly
  • Java,perl,php,python,ruby, VB script

C#,html.

  • Firefox, IE, GChrome, IE, Firefox, GChrome.

Safari, opera.

  • Windows, MAC, Linux. Windows.
  • Flexible &Extendable. Flexible & Extendable less.
  • Web apps & Mobile apps Desktop, Web, Mobile apps.

Note:-

Selenium is for web and mobile applications. If any desktop components or fields available in the application cam handled with the help of SIKULI or AUTOIT.

When to start automation for a project?

  • When the application is stable to save the regression testing time when can go for automation.
  • If you are using agile process (Scrum model) then we don’t wait until the build is stable. The requirements/sprints/iterations are stable. Then we can go for automation
  • We should have the budget and approval mail from the client or lead to start automation.

What kind of application can be automated by using selenium?

  • Selenium supports all kinds of web applications and mobile applications irrespective of the language.
  • We can use any supported language to automate all the applications.

C Users atish Desktop testing2 png

What is automation strategy/ approach/ automation life cycle to automate one project?

  • Check that whether the application is compatible or not with the tools (Selenium).
  • Execute or review all the test cases at least once, to get the functional knowledge on the application and to identify the test cases which are feasible for automation.
  • Provide the automation estimation for all the identified testcases.(The no of days which we are taking to automate the test cases is known as Automation Estimations)
  • Develop POC and deliver it to client (Automate 2 to 3 scenarios by using framework and deliver to client)
  • Prepare or identify the framework for the project.
  • Develop the scripts for all the identified test cases.
  • Once the scripts are stable then integrate in a hierarchical order to execute.
  • If any new build released update the scripts as for the new build.
  • Execute the scripts and capture the results in anew folder.
  • Analyse the results and identify the bugs.
  • Report the bugs manually to the developers by any reporting tool like bugzilla, QC, Jira, etc.

Selenium components:-

The selenium is majorly built on below components.

  1. Selenium IDE (Integration Development Environment)
  2. Selenium RC
  3. Selenium grid
  4. Selenium web driver
  5. Selendroid and appium
  6. Winium

Selenium IDE:-

  • IDE stands for Integrated Development Environment
  • It is to record and run the script.
  • It is an add-on for Firefox(we can install and record in Firefox browser only).
  • It is accountable for user actions(for each and every action it will generate the script).
  • By default it will generate the script in html language. If required we can convert to other supported language like java, .net, etc.
  • The recorded scripts can be run against other browsers also with the help of RC or web driver.

Selenium RC:-

  • RC stands for Remote Control.
  • It is the selenium1 and introduced in 2004 by jasonhuggins.
  • It is a server which is responsible to launch all the browsers but one browser at a time.
  • We can able to automate the entire application by using selenium RC.

Selenium web driver:-

  • It is the selenium2& 3 and it is an advanced version of RC.
  • The limitations which are identified in RC are overcome in web driver and also given the added advantages.

Selenium Grid:-

  • It is for parallel execution. We can launch all the browsers parallel and the scripts can be executed in all the browsers parallel at a time.
  • Maximum of 5different browsers can be launched by using grid.

Selendroid:-

  • It is to test the mobile apps on the android platform. it is to test on less than 4 android versions

Appium:-

  • It is to test the mobile applications on both android and iOS platforms. If the android version is more than 4 we need to use Appium

Steps to install selenium IDE in Firefox browser:-

Selenium IDE will be availableunder tools.

Describe the steps to record the scenario like open google.com type selenium4testing in the test box then click on Google search.

  • Open Firefox, go to tools, then click on selenium IDE.
  • By default it will be in recording mode.
  • If it not in recording mode then click on red button to start the recording.
  • Minimize the tool then perform or execute the test steps on the browser.
  • Once the recording is completed, restore or maximize the tool then click on the red button to stop the recording.
  • By default the selenium IDE will give the recorded actions in two formats.
  1. Table
  2. Source
  • Table contains all the recorded actions in a tabular format.
  • Source contains the same recorded actions in the form of source code(By default HTML).
  • To execute the recorded scripts we have two options.
  1. Play current test cases.
  2. Play entire test suite.
  • To maintain the synchronization make the execution speed slow by using the option fast--slow.
  • Synchronization is to provide wait to the tool to maintain in-sync between both application and tool.
  • To save the recorded script we have the option like go to file, click on save test case as and save the test case in .html extension.
  • To open the recorded script go to the file click on open and open the desired scripts.

Test suite / batch execution:-

Combination of multiple test cases is known as test suite or batch.

Scenario: Describe the steps to execute multiple test cases by using play entire test suite option

  • Open selenium IDE then record the first test scenario. Once the recording is completed click on the red button to stop the recording.
  • Take a new test case by navigation to file then click on new test case. Then record the scenario make sure that the selenium IDE is in recording. Once the recording is completed click on the red button to stop the recording.
  • Use the option play entire test suite to execute all the test cases in sequential order.

Limitations or disadvantages selenium IDE:-

  • Its not possible to perform regression testing.

Ex:- The recorded scripts can't be executed on the new build if the application is dynamically changing.

  • We can't perform retesting of the application

Ex:- Test the login functionalitywith multiple sets of different credentials.

Test the one way search functionality with multiple sets of origin.

  • Static testing like checking the availability of the fields (validation) is not possible to perform.
  • We cant perform database testing
  • It is limited to firefox browser only.
  • It won't provide the detailed test report or build status report for the analysis.
  • The above all can be performed by using RC or Web driver.

Advantages of selenium IDE or when to use selenium IDE(recording):-

  • To check whether the application is compatible or not can be identified by using selenium IDE.

Ex:- Record few scenarios and check that whether the tool is generating the script or not.

  • If it is generating the scripts then we can conclude that the application is compatible with selenium..
  • If you are facing any problem to identify the locator/target then it can be overcome by using selenium IDE.(We can take the locator from Selenium IDE)
  • We can convert the recorded script to specific language and it can be used in the scripting also.
  • To convert the recorded scripts go to options then click on options then check the check box Enable experimental features then click on ok.
  • Now go to options, click on format and select the desired language.

NOTE:-

  • When to go for scripting and when to go for recording for a project automation?

To automate any project we have to use the scripting by using webdriver while scripting if you are facing any issues then it can be overcome by using selenium IDE.

Note: If we are getting more than 50 version of firefox will get JS execution error. To overcome the issue install the below add on in firefox

How to configure or setup the selenium with java?

To configure selenium we need below files

Eclipse

JDK or JRE (8)

Selenium_server_standalone_3.4.0.jar

RC, Web driver2&3 and Grid

Eclipse:-It is a standalone file(normal file) or folder. It is an editor whare we can write the scripts

  • It is not necessary to install it
  • Based on the System type (32 bit or 64 bit)we need to download Eclipse

JDK/JRE:- JDk stands for java development kit.

JRE stands for java run time environment.

Both are nothing but java.

  • To open eclipse java should be installed in your system.
  • Go to the path C:\Program Files\Javaand check that JRE 6/7/8 is available or not. If it is not available then install JDK 7/8 exe file based on the system type

Selenium-serve_ standalone jar file:-

  • It is the selenium where it’s a combination of RC and web driver, grid.
  • Take the eclipse and extract the zip file.
  • Copy to any desired drive.
  • Check that JRE 6/7/8 is available in c:/programme file/java. If is not available then install JDK.
  • Create a folder with a name lib/library copy the selenium server standalone jar file and paste it in the library folder.
  • Go to eclipse then double click on blue icon (eclipse.exe) continue to open.
  • By default if displays some path in the workspace if required we can update the path.
  • Workspace is the folder where it contains the test scripts click ok in workspace launcher window.
  • Click on workbench to navigate into eclipse

Create a project

  • By navigating to a file,click on new and select project.
  • Select the java project then click on next.
  • Give the project name as selenium automation.
  • Check that java SE 1.8/1.7/1.6. From the field use an execution environment JRE then click on finish.
  • Click on s2 to continue the setup.

Expand the selenium automation project

  • Right click on JRE system library click on build path then select configure build path.
  • Click on add external Jars and select selenium server standalone jar file from the library folder.
  • Click on open and ok.
  • Go to run then click on external tools and select in that we are having external tools configurations.
  • Double click on the programme click on browse file system at location select java or java.exe from the below path c:\programme file\java\jre8\bin\java.exe.
  • Click on browse file system at working directory select library folder then click ok d:\library (it should contain the selenium server standalone jar file).
  • Give the argument as jar selenium server standalone 2.46.0 JAR click on apply and click on RUN.

Write a programme to verify the search in google.co.in?

  • Take a class by write click on the project click on new and select class.
  • Give the package name as selenium WebDriver.
  • Give the class name as OpenUrl_HMS
  • check the checkbox public static void main then click on finish.

Package:-

Package is nothing but a folder where it contains the classes .The package will be created under the SRC folder of the selenium project.

Class:-

  • Class is a blue print of templates it contains object.
  • Object can be anything which should be physically available.
  • In java the object is nothing but the data type or method or instance.

Public static void main:-

  • It is the main method which is responsible for Execution

Program1: Write a program to open the URL

Sample program by using webDriver

Refer the Programs from selenium4testing.com/downloads

Package: webdriver

Classname: HMSLogin.java

Webdriver commands:

Webdriver methods:

Scenario2:- write a program to test the login functionality of hms by using the credentials user1 and user1

Refer the Programs from selenium4testing.com/downloads

Package: webdriver

Classname: HMS_Login:-

  • Take a new class by rightclicking on the project ,click on new and select class.
  • Give the pacage name as Webdriver, And give the class name as HMS_logn ,thencheck the checkbox public static void main then click on finish
  • To perform action on any field we need the locator.we can To take the locators for every browser we are having the below addon.
  • To take thelocator,right click on the field click on inspect element(Q),then use either ID or Name or any locator.

Browser Addon

  • Fire fox inspect element
  • IE developer tools
  • Google chrome inspect element
  • Safari inspect element
  • Opera inspect element

Scenario3:- write a program to test the login functionality of yahoo by using the credentials.

Refer the Programs from selenium4testing.com/downloads

Package: webdriver

Classname: Yahoo_Login

------Add content

Scenario4:- write a program search for “selenium4testing in google.co.in

Refer the Programs from selenium4testing.com/downloads

Package: webdriver

Classname: OpenURL_Selenium4Testing

Scenario 5:-write a program to test the login functionality of facebook.com

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname: facebook_login

Scenario 6:write a program to verify the password registration in HMS

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname: HMS_PR_REG_para.java

  • How to click on link :-

// To click on link

driver.findElement(By.linkText(“manualFAQs”)).click();

driver.findElement(By.linkText(“seleniumFAQs”)).click();

  • How to click on dropdown:-

//For drop down

newSelect(driver.findElement(By.id("idname"))).selectByVisibleText("3 Adults");

new Select(driver.findElement(By.id("idname"))).selectByVisibleText("1 Child");

  • How to click on Date& how to use x-path

driver.findElement(By.name("name")).click();

driver.findElement(By.Xpath("Xpath")).click();

  • How to Upload a file:-

By using sendkeys command we can upload a file,whare we need to provide the path of the file

//Upload a file

driver.findElement(By.name("image")).sendkeys(“path”);

  • In java when we ever we are going to give path then we have to use double slash(//).

Scenario7: complete the HMS permanent registration

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname: HMS_PR_REG_para.java

Scenario 8:- write a program to login in to HMS and click on ADT then enter all the values in new admition fields

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname:HMS_newadmin

Scenario 9:-write a program to test the login functionality of gmail by using the credentials testingse2 password selenium@345

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname:GmailLogin

Synchronization:-

The process of providing wait to the tool to main the insync between both application and tool is known as synchronization. It is two types.

1. page load

2. page refresh

Page load:-

  • If the application is taking time to load the page then the webdriver by default handles it. Not necessary to add any command

Page refresh:-

  • If the application taking time to refresh the page then we need to handle with the help of below command.

Selenium thread.sleep(time);

(or)

Implicit/Explicit wait

  • It is a standard wait its simply waits upto the given time..
  • Thread.sleep is form of java command. Whenever we use it may through the exception.
  • To handle it add throws exception to the method as well as to the main method.

Scenario10:-Write a program to test the login functionalities of a gmail.?

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname: GmailLogin

Scenario11:- Write a program to verify the one way search from Hyd to banglore in spicejet

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname:Spicejet_Search

Core java basics:-

Java is an object oriented programming language. It has multiple data types like int, float, char, double, string, arrays, etc.

  • We are also having class datatype as non primitive datatypes like Strings&arrays

String:-

It is a class data type where we can store multiple characters. We can declare the string(object) in 2 ways.

1. locally

2. globally

(To comment multiple lines select multiple line ctrl+ shift+ backward slash )

Local declaration:-

If we declare the variableslocally with in any block/ method then the scope of that reference variable is limited to thatblock only. Local variables cant be used outside of the block.

Global declaration:-

If ypu are planning to access the object(data types, methods and instances ) in multiple classes and methods then we need to declare it globally by using access modifiers like private, public, protected, default.

Private:-

These objects can be used with in the class only. Private objects cant be used outside of the class.

Public:-

These objects can be used within the classes as well as outside of the class. Public object can be used with in the project of multiple classes& packages

Methods (or) Functions:-

  • Group (or) block of statements is known as Method
  • Methods are reusable
  • Method should have a unique name
  • We can call the method with in the method also
  • We can declare the method in two formats

1) Non Static

2) Static

Scenario 12:- writea program to print 3 statements (welcome) messages

Refer the Programs from selenium4testing.com/downloads

Package: webdriver new

Classname:

Parameterization:

The process of sending/passing the values(parameters) to the method from the main method is known as parameterization.

Syntax:-