Tuesday, 14 February 2017

SQL——DCL Commands

Data Control Language(DCL) is used to control privilege in Database.Data Control Language(DCL) is used to control privilege in Database.
DCL defines two commands,
  • Grant : Gives user access privileges to database.
  • Revoke : Take back permissions from user.

TO ALLOW A USER TO CREATE SESSION

grant create session to username;

TO ALLOW A USER TO CREATE TABLE

grant create table to username;

TO PROVIDE USER WITH SOME SPACE ON TABLESPACE TO STORE TABLE

alter user username quota unlimited on system;

TO GRANT ALL PRIVILEGE TO A USER

grant sysdba to username

TO GRANT PERMISSION TO CREATE ANY TABLE

grant create any table to username

TO GRANT PERMISSION TO DROP ANY TABLE

grant drop any table to username

TO TAKE BACK PERMISSIONS

revoke create table from username


SQL—DML Commands

Data Manipulation Language (DML) statements are used for managing data in database. DML commands are not auto-committed. It means changes made by DML command are not permanent to database, it can be rolled back.
It has three Attributes: 1. Insert 2.Update 3. Delete
  1. Insert :Insert command is used to insert data into a table. Following is its general syntax.
INSERT into table-name values(data1,data2,..)
Lets see an example,
Consider a table Student with following fields.
S_idS_Nameage
INSERT into Student values(101,'Adam',15);
The above command will insert a record into Student table.
S_idS_Nameage
101Adam15

EXAMPLE TO INSERT NULL VALUE TO A COLUMN

Both the statements below will insert NULL value into age column of the Student table.
INSERT into Student(id,name) values(102,'Alex');
OR
INSERT into Student values(102,'Alex',null);
The above command will insert only two column value other column is set to null.
S_idS_Nameage
101Adam15
102Alex

EXAMPLE TO INSERT DEFAULT VALUE TO A COLUMN

INSERT into Student values(103,'Chris',default)
S_idS_Nameage
101Adam15
102Alex
103chris14

Suppose the age column of student table has default value of 14.
Also, if you run the below query, it will insert default value into the age column, whatever the default value may be.
INSERT into Student values(103,'Chris')

2. Update Command
Update command is used to update a row of a table. Following is its general syntax,
UPDATE table-name set column-name = value where condition;
Lets see an example,
update Student set age=18 where s_id=102;
S_idS_Nameage
101Adam15
102Alex18
103chris14
3. Delete Command
Delete command is used to delete data from a table. Delete command can also be used with condition to delete a particular row. Following is its general syntax,
DELETE from table-name;

EXAMPLE TO DELETE ALL RECORDS FROM A TABLE

Consider the following Student table
S_idS_Nameage
101Adam15
102Alex18
103Abhi17
DELETE from Student where s_id=103;
The above command will delete the record where s_id is 103 from Student table.
S_idS_Nameage
101Adam15
102Alex18

Monday, 13 February 2017

SQL—Structured Query Language

Introduction
SQL stands for structured query language which comprises of fundamental building blocks of databases,it is used to defined the method used to create  and manipulate relational databases on all major platforms.
SQL was originated in 1970 in IBM San Jose laboratory where it was used as the relational database language for System-R DBMS.  Successful outcome of this project at 1979, made SQL becoming popular among many RDBMS vendors
SQL received certification from American National Standard Institute (ANSI) and from International Standard Organisation (ISO) in 1986. There are number of advantages in using a standardized relational language such as reduced training costs, application portability, application longality, reduced dependence on a single vendor and cross-system communication
There are three types of SQL commands
  1. Data definition language (DDL) – these commands are issued to create, alter or delete tables.  Usually these commands can be executed by database administrator only to prevent any accidental or deliberate damage to the database.
  2. Data manipulation language (DML) – these commands are used to insert, update, delete or query data from tables.
  3. Data control language (DCL) – these commands are used to grant various access privileges of the database structure to users.  Only the database administrator can execute these commands.
DDL Command
It has three attributes : 1. Create 2. Alter 3. Delete
  1. Create
    The create table command defines each column of the table uniquely. Each column has minimum of three attributes.
    • Name
    • Data type
    • Size(column width)
    The Structure of Create Table Command
     Column nameData type Size
     Reg_no varchar2 10
     Name char 30
     DOB     date 
     Address varchar2 50
    Example:
     
    CREATE TABLE Student
                 (Reg_no varchar2(10),
                  Name char(30),
                  DOB date,
                  Address varchar2(50));
    The DROP Command
    Syntax:
    DROP TABLE <table_name>
     
  2. Example:
    DROP TABLE Student;
    It will destroy the table and all data which will be recorded in it.
    The TRUNCATE Command
Syntax:
TRUNCATE TABLE <Table_name>
 
Example:
TRUNCATE TABLE Student;
The RENAME Command
 
Syntax:
RENAME <OldTableName> TO <NewTableName>
 
Example:
RENAME <Student> TO <Stu>
 
The old name table was Student now new name is the Stu.
The ALTER Table Command
 
By The use of ALTER TABLE Command we can modify our exiting table.
Adding New Columns
 
Syntax: 
ALTER TABLE <table_name>
         ADD (<NewColumnName> <Data_Type>(<size>),......n)
Example:
ALTER TABLE Student ADD (Age number(2), Marks number(3));
 
The Student table is already exist and then we added two more columns Age and Marks respectively, by the use of above command.
 
Dropping a Column from the Table
 
Syntax:
ALTER TABLE <table_name> DROP COLUMN <column_name>
 
Example:
ALTER TABLE Student DROP COLUMN Age;
 
This command will drop particular column 
 
Modifying Existing Table
 
Syntax:
ALTER TABLE <table_name> MODIFY (<column_name> <NewDataType>(<NewSize>))
 
Example:
ALTER TABLE Student MODIFY (Name Varchar2(40));
 
The Name column already exist in Student table, it was char and size 30, now it is modified by Varchar2 and size 40.
 
Restriction on the ALTER TABLE
 
Using the ALTER TABLE clause the following tasks cannot be performed.
  • Change the name of the table
  • Change the name of the column
  • Decrease the size of a column if table data exists

Saturday, 11 February 2017

Captcha which could be automated.

1- Captcha which could be automated-
This is the example from-  http://www.indianrail.gov.in/pnr_Enq.html 
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class CaptchaAutomated {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.indianrail.gov.in/pnr_Enq.html");
String captchaValue = driver.findElement(By.xpath("//span[@id='txtCaptchaDiv']")).getText();  //this will read the captcha
System.out.println(captchaValue);
driver.findElement(By.xpath("//input[@id='txtInput']")).sendKeys(captchaValue);
}
}
Output-  This program will read the captcha and will enter the value of captcha in the Enter Captcha box.
2- Captcha which could not be automated-
This is an example from - https://signup.live.com/signup.aspx
Such kind of captcha can not be automated.

If any text box is disabled then how to send the value to that box ?

mport java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Naukari{
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get(“http://www.naukri.com&#8221;);
driver.findElement(By.partialLinkText(“Post Resume”)).click(); //click in post resume
WebElement user= driver.findElement(By.xpath(“//input[@id=’txt2′]”)); //Enter your Email ID* : , textbox
System.out.println(user.isEnabled()); //this will give false
//user.sendKeys(“hello1”); //if u will try this, this will fail
((JavascriptExecutor)driver).executeScript(“document.getElementById(‘txt2′).value=’raj'”); //this is how , to use javascript to send value
WebElement pass = driver.findElement(By.xpath(“//input[@id=’password’]”)); //this field is not disabled so for this sendKeys() method can be used.
System.out.println(pass.isEnabled()); //this will print true
pass.sendKeys(“hello”); //this will send the value in, Create a Password for your account* :
}
}
Note: Use javascript because if any textbox is disabled then in that case sendKeys() method will not work

VerifyTextPresentInWebPage(Selenium WebDriver)

package seleniumconcepts;

import java.util.concurrent.TimeUnit;

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

public class VerifyTextPresentInWebPage {

/**
* Author by Rajat Tiwari
*/
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.goibibo.com/");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
     //verify 'International Flights' text is there in the web page or not
       String expText = "International Flights";
     //first way to verify by using locator and getText() method
       String actText = driver.findElement(By.xpath("//a[@class='hm_inactive']")).getText();
       if(actText.contains(expText)){
           System.out.println("1) Expected text '"+expText+"' present in the web page.");
       }else{
           System.out.println("1) Expected text '"+expText+"' is not present in the web page.");
       }
       //second way to verify by using getPageSource method
       String pageSource = driver.getPageSource();
       if(pageSource.contains(expText)){
           System.out.println("2) Expected text '"+expText+"' present in the web page.");
       }else{
           System.out.println("2) Expected text '"+expText+"' is not present in the web page.");
       }
       driver.close();
   }


}

Monday, 23 January 2017

HP ALM Tools(Quality Centre Tools for test management Tools

                          H.P Quality Centre (Test Management Tools)

It is a test management tool which manages the whole entire testing activities. It was

initially developed by Mercury interactive. It is now developed by H.P. It is also called

Application Lifecycle Management Tools.

It manages the entire software lifecycle right from requirement collection till it is

deployed to the production Server.

The various people who is involved in the project are

1. Business Analyst

2. Developer

3. Test Engineer

4. Project Manager

5. Product Owner

How to Install HP ALM

The latest version is HP ALM is 12.0

Part A: Downloading

Step 1: Go to HP ALM Site http://www8.hp.com/us/en/software-solutions/alm-

software-development- testing/try-now.html

Step (a): Select “Try Now” Tab

Step (b): Click “download HP ALM Now” Button.

Step 2: Download Appears

 Enter all the details

 Click “ Next”


Step 3: Accept Agreement Terms and click “I Agree”

Step 4: Select installer for Windows, shown below

Part B :) Installation

Step 1:

 Unzip the file and store in the appropriate drive

 Right click the setup.exe and Run as Administrator

Step 2: Select ALM Platform for Installation for windows environment. The

extraction process will continue

Step 3: The welcome page for the installation will happen click on Next

Step 4: Upon click on Next the Agreement page will open. Upon Accepting that

the procedure for installation will start.

Step 5: Choose the appropriate drive for the installed file.

Step 6: An installation Summary will be shown before proceeding to the next

steps.