Earn Money in 10 days

Selenium Videos

Protractor In Selenium

Livechat

Saturday, 7 March 2015

Scrolling using Selenium WebDriver


Selenium Webdriver doesn't provide an inbuilt method for page scrolling
By using JavaScript interface we can scroll in Page(Horizontal,Vertical).
We need to import this packege import org.openqa.selenium.JavascriptExecutor;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ScrollDemo {
 public static void main(String[] args) throws Exception {
   WebDriver driver=new FirefoxDriver();
   driver.manage().window().maximize();
    driver.get("http://facebook.com");
   Thread.sleep(5000);
 JavascriptExecutor jse = (JavascriptExecutor)driver;
  jse.executeScript("scroll(0, 1500)"); //y value  can be altered
  Thread.sleep(5000);
   JavascriptExecutor jse1 = (JavascriptExecutor)driver;
  jse1.executeScript("scroll(250, 0)"); //x value can be altered
 }}


Output:First it will scroll down(Y axis) and after 5 seconds it will scroll up(X axis).

Friday, 6 March 2015

Agile Methodology

Why choose Agile Scrum Methodology?

Due to frequent change in requirement we work on Agile Scrum Methodology.

Its like an incremental model .In agile whole requirement of a software product divides according to priorities.These priorities are saved in a list which is called product backlog.



Product owner
In Agile process product owner will decide all the requirements for a software.
Product owner is a scrum development role for a person who represents the business or user community and is responsible for working with the user group to determine what features will be in the product release.
Product Backlog:
All the user requirements are saved in product backlog.Product owner will decide which user story's he/she wants to complete first.Then according to that their will be a sprint meeting.
What is Sprint Meeting:
In sprint meeting all the team member(developers,testers) will participate for each release of a product that is called sprint.
In sprint meeting all the team members understand the modules and requirements and give their estimate for each task.
Sprint:
Sprint is of 1-2weeks in which we complete 4-5 user stories according to software priorities.
Scrum:
Scrum is of multiple sprints in which we complete multiple user stories 
Scrum Master:
Scrum Master keeps the track of the Software Product.
Scrum Master conduct a daily stand up meetings with all the team members everyday for 20-30 mins.
The scrum master asks the team members these three questions: 
1. What did you do yesterday?
2. What will you do today?
3. Are there any impediments in your way?
Sprint BackLogs:
The sprint backlog is a list of tasks identified by the Scrum team to be completed during the Scrum sprint. During the sprint planning meeting, the team selects some number of product backlog items usually in the form of user stories, and identifies the tasks necessary to complete each user story. All the team members give their  estimates how many hours will take to complete their tasks.
Sprint BurnDownChart:
The sprint burndown chart is a public displayed chart showing remaining work in the sprint backlog. Updated every day, it gives a simple view of the sprint progress. 
Retrospective meeting:
After the release of each sprint all the team members discuss how the sprint was.How can we improve our product qualtity.

Sunday, 1 March 2015

Test Plan Template

What is Test Plan

It is our official document which will decide  what we are going to test, when we will test and how we are going to test the in-scope requirements.
BY ISTQB Defination 
Test plan: A document describing the scope, approach, resources and schedule of intended test activities. It identifies amongst others test items, the features to be tested, the testing tasks, who will do each task, degree of tester independence, the test environment, the test design techniques and entry and exit criteria to be used, and the rationale for their choice,and any risks requiring contingency planning.






    Basically Test plan will be prepare by Testing Lead. Tester 
   will just gothrough the document and write the testcases and 
 executes.

1.Objectives and Scope:

This document provides a high level view of the type of test that is scheduled to be carried out and the features that will and will not be tested.

The objective of this document is to test the functionality of the Facebook Application.(Write your Application Name)

2       Features to be tested
FaceBook - Release 1:
The features which are to be tested, are:
1.    LoginPage
2.    Home Page
(Write Modules According to Your Application)
2.1      Features not to be Tested
3       Approach

In Approch You can write which model You are Going to follow.

Agile Methodology with scrum.

WaterFall 

3.1 Types of Testing

This document provides different types of testing for Facebook Application.

1.    Static Testing

This testing does not need computer as the testing of program is done without executing the program. For example:  reviewing, walk through, inspection of the documents

2.  Dynamic Testing

a)Smoke Testing
b)Functional Testing
c)Retesting and Regression Testing
d)E2E Testing
e)Integration Testing
f)UAT


The testing will initiate with the review of the user requirement documents.

The first type of tests to be carried out will be Smoke and functional testing to determine that each of the individual features perform the functions for which they have been specified. After this a full set of end-to-end test scenarios will be identified once all the features have been delivered and tested, for this a set of e2e scripts would be produced which will seek to exercise the various workflow scenarios specified. This will be followed by system integration testing and UAT/CAT

                                      
Smoke Testing:

Smoke testing covers most of the major functions of the software. The result of this test is used to decide whether to proceed with further testing. If the smoke test passes, go ahead with further testing.

Functional Testing:

Functionality testing will be performed for all the functionalities of the application which will covers all the screens including inputs and outputs fields, buttons graphics and all the navigational flow between the screens.
 Regression Testing

Regression testing will be performed once a defect has been fixed and also if there any enhancements. The scope of this testing will depend on the nature of the defect fixed, but will include at least a re-run of the test where the defect was first identified and, any tests required to get the system into the state at which the problem was identified.

End-2-End Testing

A full end-2-end test will be carried to verify the flow of the process and to exercise all specified work flow route.

UAT/CAT Testing

User Acceptance/Customer Acceptance Testing phase will be performed to ensure that all the functionality scheduled for  delivery meets the business requirements.

Test Case Preparation

The test cases will be generated using JIRA,TFS,QC(Test Management Tool) and also in the excel sheet by the QA team lead. Requirement Traceability Matrix(RTM) will also be generated to make sure that all the requirements are covered 100%

Test Execution

The tester will carry out the execution based on the availability of the functionality and adequate release notes from the development team. Entry criteria for the system test stage are described below.

The Test Results will be updated as Passed, Failed, or Not Completed and a test completion test summary report will be produced at the end by the QA team lead.


All bugs found during the testing phase will be reported using the defect tracking tool JIRA,TFS,QC(Test Managemet Tool) The tester will assign the defect to the development team. Once the developer fixes the defect, the status of the defect is changed to Awaiting QA. The tester will then retest the defect in the latest build available and change the status of the defect to Done/Failed QA accordingly.

3.2 Entry Criteria
Entry criterion is used to determine when a given test activity should start. It also includes the beginning of a level of testing, when test design or when test execution is ready to start.
  • Test enviornment are ready to use like  browser (if web application), Tablets or Devicesif(Mobile Application)
  • Test tools installed are ready to use
  • Test data is available 
3.3      Exit criteria
    All entry criteria met.
    Test Summary Report has been produced, reviewed and approved by the Delivery Manager.

     All Critical, High and Medium priority defects have been retested and closed.

 3.4 Item Pass/Fail Criteria
  Specify the criteria that will be used to determine whether each test item (software/product) has passed or failed testing.
A test will be considered passed if the actions described in the test meet the ‘expected output’ for all steps described in the test case.
 If the output is not as expected, it will be reported and investigated to determine where the problem lies. 
3.5 Suspension Criteria and Resumption Requirements
Testing may be suspended under the following circumstances: -
A discrepancy between the information contained in the Requirements, the Work Flow diagrams and the software delivered.
The delivered functionality is not functioning well enough for the tests to be meaningful
A defect is found in the software, which means that further testing is impossible
A defect is found in the software which affects further test cases, or renders them inoperable
The following activities must be carried out on resumption of testing: -
Checks must be carried out on any corrections which have been made, to ensure that the corrective action does not affect the rest of the system (Regression)
Unless the tester is absolutely certain about the impact of a change, then the entire Test will be re-run 
New test cases may have to be written to test the changes
The system must be restored to a known stable state before testing commences
3.6 Test Deliverables:
List test deliverables, and links to them if available, including the following:
Test Plan (this document itself)
Test Cases
Test Scripts
Defect/Enhancement Logs
Test Reports
4.Test Enviornment 
Specify the properties of test environment: hardware, software, network etc.
List any testing or related tools like Selenium, qtp,Sahi

5       Test Data

All test data identified will be specified in a separate document, i.e.Test Data Specification document.

6      Test tools

Test management tool JIRA,TFS,QC will be used during this project  for all Test Cases.
JIRA will be used for defect reporting and management.
Selenium  and Qtp is also introduced for Automation testing which will be used if the time permits.    

7       Responsibilities



  1.      The preparation and execution of the testing will be carried out by the Quality Analyst Test Team
  2.       The development team will provide the environment specification
  3.  The Business Analyst team will provide with all the user stories and use cases.
  4.  Quality Analyst will review all test products (specifications, reports, etc.).
8    Resource
QA test analysts will carry out the test preparation phase.
QA Team Lead – DDM,
QA Test Analyst – Ritika

 9.     Schedule

The test cases to be executed would have been identified from the relevant use case specification in this project it is from the user stories created in JIRA,

Test Estimation is like How many user stories we have.Based on user stories how many test cases we can write.How many total test script we can write.Its like an estimation of whole project.
11.Risk  and Contignious


12   Defect Management/ Problem Severity 

All problems found during the testing phases will be logged uing JIRA,  each problem will be assigned a severity by the QA team; the classification of defect reporting is given in the table below.  The delivery manager will make the final decision on severity classifications in the event that there are any disagreements.  The developers shall also use these severity definitions for problems that they identify during their Unit testing.

Severity 


1 Critical – the system is broken and cannot be used, major functionality is impaired, or there is data loss. There are no workarounds. Problems are so severe that the timescales cannot be met. Testing may need to be suspended and the problem resolved.

2 Major - the fault renders several system elements unusable, or affects one or more system elements. Workarounds exist which may be unacceptable to the customer. Problems that will jeopardise the launch unless corrected.

3 Medium - the fault affects system elements that are not key to the overall functionality of the system.   The system continues to produce correct results and data is not affected. Acceptable workaround may exist.

4 Low/Trivial – this fault barely affects the quality of a system and will only be fixed if time permits.

Wednesday, 25 February 2015

How to send a attachment via gmail using Selenium(Using Robot Class)

Scenario:

Open gmail.com
Enter username 
Enter Password
Click on SignIn
Click on composeButton
Add recipent
Add Subject
Click on attachment
Add your File location
Click on Send Button


import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class SendFile {
public static void main(String str[]) throws InterruptedException, AWTException{
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.gmail.com/");
//open gmail
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("enteryouremailid");
//enter emailid
driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("enteryourpassword");
   // enter password
driver.findElement(By.xpath("//*[@id='signIn']")).click();
//click on sign in
driver.findElement(By.xpath("//div[contains(text(),'COMPOSE')]")).click();
//click on compose button

driver.findElement(By.xpath("//form[1]//textarea[1]")).sendKeys("ritu7181@gmail.com");
//enter email id where you need to send email

driver.findElement(By.xpath("//div[@class='aoD az6']//input[@class='aoT']")).sendKeys("Please find attachment");
//Enter subject
     Thread.sleep(15000);
driver.findElement(By.xpath("//div[@class='a1 aaA aMZ']")).click();
//click on attachment icon
StringSelection ss = new StringSelection("C:\\Users\\Ritika Gulati\\Downloads\\Asp.docx");
    //upload your file using RobotClass
    //attach your path where file is located.
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
    Robot robot = new Robot();
    Thread.sleep(5000);
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_V);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_V);
    Thread.sleep(6000);
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.keyRelease(KeyEvent.VK_ENTER);
    Thread.sleep(10000);
      driver.findElement(By.xpath("//div[text()='Send']")).click();
    //Click on send
   }
}

Wednesday, 7 January 2015

What is Maven

If we have to test any web application using  Selenium everytime we need to download jar files from http://docs.seleniumhq.org/download/ and configure into eclipse.If we need test reports or any jar files we first download and add into in our Project.But maven has solved this problem for us By using Maven we just have to add dependecies in Pom.xml files and it will downloaded all the Jar files from Server.
What is Maven
Maven – a build automation tool which is distributed under Apache Software Foundation.
What is pom.xml file.
Its the core of maven.If we need any jar files in our projects we just need to add dependencies of those jar files in Pom.xml.When maven runs it will download all the jar files from apache server.
For reference you can use this http://docs.seleniumhq.org/download/maven.jsp
If you need any jar file like poi jar or Selenium jar files  files you just need to add dependencies in POM.XML File.It will download all the jars from server.


This is pom.xml File.If you will use Maven You will get this in your project.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com..framework.datadriven</groupId>

  <artifactId>DemoProject</artifactId>
  <version>1</version>
  <packaging>jar</packaging>

  <name>Datadrivenframework</name>

  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties> 
   <dependencies>
          <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.1.1</version>
           <scope>test</scope>
          </dependency>
         <!-- Selenium -->
       <dependency>
                  <groupId>org.seleniumhq.selenium</groupId>
                  <artifactId>selenium-java</artifactId>
                  <version>2.42.2</version>
            </dependency>
         <!-- POI -->
         <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>3.6</version>
         </dependency>
         <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>3.6</version>
         </dependency>
        <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml-schemas</artifactId>
      <version>3.6</version>
        </dependency>
        <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.1</version>
      </dependency>
      
      <dependency>
      <groupId>org.apache.xmlbeans</groupId>
      <artifactId>xmlbeans</artifactId>
      <version>2.3.0</version>
      </dependency>
      <!--  Log4J  -->
      <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
      </dependency>
      <!-- JavaMail  -->
      <dependency>
      <groupId>javax.mail</groupId>
      <artifactId>mail</artifactId>
      <version>1.4</version>
      </dependency>  
        </dependencies>
          <build>
      <plugins>
                  <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <!--  suiteXmlFiles>
       <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>    
                </suiteXmlFiles-->
              </configuration>
            </plugin>        
    </plugins>
      </build>
    <reporting>
        <plugins>
        <!-- TestNG-xslt related configuration. -->
          <plugin>
            <groupId>org.reportyng</groupId>
            <artifactId>reporty-ng</artifactId>
            <version>1.2</version>
            <configuration>
              <!-- Output directory for the testng xslt report -->
              <outputdir>/target/testng-xslt-report</outputdir>
              <sorttestcaselinks>true</sorttestcaselinks>
              <testdetailsfilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testdetailsfilter>
              <showruntimetotals>true</showruntimetotals>
            </configuration>
          </plugin>
        </plugins>
      </reporting>
</project>
This pom.xml will download automatically when maven 


How to download Maven

Go to this link
Step1:
You will Get a Zip folder.Extract this Zip file into Your suitable Drive.
Note:This configuration is very simple as you have configure java and ant into Your System.
Step2:
After extracting you will get this folder.

Step3:Set up maven in Environment.Go to Environment Variable.


Step4: Click on Environment Variables.

Step5: Click on New


Step6:  In variablename Textbox: Write M2_HOME.
           In variable Value Give the path of Your Apache maven upto Bin Folder.





Step7:Go to Path in System Variable.Click on Edit

Step8:Set maven path as Write ;%M2_HOME%\bin 


Step9:Open cmd prompt.
Step10: Type in cmd Prompt --version and Press enter.

Step11: Output.Maven is Installed Successfully.

How to work with Maven will Tell You in The Next Post.

Sunday, 4 January 2015

How to run your Script on Multiple Browsers In Selenium

Now a Days  it has now become crucial to test web applications on multiple browsers. On different browsers, client components like Javascript, AJAX requests, Applets, Flash, Flex etc.applications on multiple browsers. Also for different browsers you may have different handling on how requests are processed on server side based on the user-agent received from client browser. So just testing your web application on single web browser is not enough. You need to make sure that your web application works fine across multiple browser.So here I will tell you how to test a web application using selenium on multiple Browser.

Four simple steps you need to follow:

Step 1: Create your Script. Using TestNG annotations. Define parameters (using @Parameters) for taking input value i.e, which browser should be used for Running the Test

Step 2: Create a TestNG XML for running your script

Step 3: Configure the TestNG XML for passing parameters i.e, to tell which browser should be used for Running the Test

Step 4: Run the TestNG XML which can pass the appropriate browser name to the Script such that the Test Case is executed in a specified browser

Parallel Test in Selenium

Create a TestNG XML for running your test. Configure the TestNG XML for passing parameters 
This is the Testng.xml.By this you can test you application on multiple browser mention in testng.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Myparalleltest" verbose="1" parallel="tests" thread-count="2">
<test name="chrometest">
<parameter name = "browser" value ="chrome"/>
    <classes>
        <class name="paralleltest.CrossBrowsertest"></class>  cop
    </classes>
</test>
<test name="firefoxtest">
<parameter name = "browser" value ="firefox"/>
    <classes>
        <class name="paralleltest.CrossBrowsertest"></class>  
    </classes>
</test>
<test name="internetexplorertest">
<parameter name = "browser" value ="ie"/>
    <classes>
        <class name="paralleltest.CrossBrowsertest"></class>  
    </classes>
</test>
</suite>

//You need to add a annotation in you java class.By using @Parameters("browser") you can run your test on multiple browser.
Create a ‘New Class’ file and refer the name to the actual page from the test object, by right click on the above created Package and select New > Class. In our case it as CrossBrowsertest
package paralleltest;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
public class CrossBrowsertest {
WebDriver driver;
@Parameters("browser")
@BeforeTest
public void openBrowser(String browser){
if(browser.equals("chrome")){
//If browser is equal to chrome
System.setProperty("webdriver.chrome.driver","C:\\Users\\Hp\\Desktop\\Chromepth\\ChromeDriver.exe");
      driver =  new ChromeDriver();
}else if(browser.equals("firefox")){
//If browser is equal to firefox
driver = new FirefoxDriver();  
}
else if(browser.equals("ie")){
//If browser is equal to ie System.setProperty("webdriver.ie.driver","C:\\Users\\Hp\\Desktop\\ie32bit\\IEDriverServer.exe");
           driver = new InternetExplorerDriver();
           driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}}
@Test
   public void doLogin() throws InterruptedException{
       driver.get("http://gmail.com");
       //Open url
       driver.findElement(By.id("Email")).sendKeys("selemiumgyan");
       //Enter email id
       driver.findElement(By.id("Passwd")).sendKeys("password");
    //   Enter password
   }}

Popular Posts

 
subscribe
Subscribe Us
emailSubscribe to our mailing list to get the updates to your email inbox... We can't wait more to have your email in our subscribers email list. Just put your nice email in below box: