Monday, July 6, 2015

Web Services Interview Question

Explain what assertion is in Soap UI ?

In SOAP UI assertion functionality is used to validate the response of request received by the Test Steps at the time of execution.  It is used to compare a part of message to some expected value.

Assertion types in SOAPUI includes

Simple contains
Schema compliance
Simple not contains
Soap Faults
Response SLA
XPath Match
XQuery Match
WS security status
Script Assertion
WS- Addressing Request or Response Assertion

SQL Interview Question

What is the difference between delete, truncate and drop command?

Delete command is a DML command, it removes rows from table based on the condition specified in the where clause, being a DML statement we can rollback changes made by delete command.

Truncate is a DDL command, it removes all the rows from table and also frees the space held unlike delete command. It takes lock on the table while delete command takes lock on rows of table.

Drop is a DDL command, it removes the complete data along with the table structure(unlike truncate command that removes only the rows).

What is the difference between sub queries and joins

Sub Queries : To write sub queries between two or more tables, there is no need to be relation exist among those tables

Joins: To write joins between two or more tables, there should be relation exist among those tables

Write SQL query to find the 3rd highest salary from table without using TOP/limit keyword

The below SQL query make use of correlated subquery wherein in order to find the 3rd highest salary the inner query will return the count of till we find that there are two rows that salary greater than other distinct salaries.


SELECT Salary
FROM Employee Emp1
WHERE 2 = (
SELECT COUNT( DISTINCT ( Emp2.Salary ) )
FROM Employee Emp2
WHERE Emp2.Salary >= Emp1.Salary
)

Write a query to rename a table name

Rename oldTableName to newTableName

What are the different types of SQL commands?

SQL commands are the set of commands used to communicate and manage the data present in the database. The different type of SQL commands are-

DDL refers to Data Definition Language, it is used to define or alter the structure of the database. The different DDL commands are-

CREATE - Used to create table in the database
DROP - Drops the table from the database
ALTER - Alters the structure of the database
TRUNCATE - Deletes all the records from the database but not its database structure
RENAME - Renames a database object

DML refers to Data Manipulation Language, it is used for managing data present in the database. Some of the DML commands are-select, insert, update, delete etc.

DCL refers to Data Control Language, these commands are used to create roles, grant permission and control access to the database objects. The three DCL commands-

GRANT - Grants permission to a database user
REVOKE - Removes access privileges from a user provided with the GRANT command
Deny - Explicitly prevents a user from receiving a particular permission(e.g. preventing a particular user belonging to a group to receive the access controls

TCL refers to Transaction Control Language, it is used to manage the changes made by DML statements. These are used to process a group of SQL statements comprising a logical unit.

COMMIT - Commit write the changes to the database
SAVEPOINT - Savepoints are the breakpoints, these divide the transaction into smaller logical units which could be further roll-backed.
ROLLBACK - Rollbacks are used to restore the database since a last commit.

Tuesday, June 23, 2015

Forward and Backward Navigation

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import webdriver

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Assigning URL to variable 'baseUrl'
baseUrl = "http://book.theautomatedtester.co.uk"

# Open the link
webDriver.get("http://book.theautomatedtester.co.uk")

# Maximize browser window
webDriver.maximize_window()

# Click on link
webDriver.find_element_by_link_text("Chapter1").click()

# Print Page Title
print(" Page Title : " + webDriver.title)

# Using Back Method
webDriver.back()

# Print Page Title
print(" Page Title : " + webDriver.title)

# Using Forward Method
webDriver.forward()

# Print Page Title
print(" Page Title : " + webDriver.title)

# This will close the browser
webDriver.quit()

File Uploading

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import  webdriver

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Assigning URL to variable 'baseUrl'
baseUrl = "http://www.htmlcodetutorial.com/forms/_INPUT_TYPE_FILE.html"

# Open the link
webDriver.get(baseUrl)

# Maximize browser window
webDriver.maximize_window()

# Upload File
webDriver.find_element_by_name("upfile").send_keys("C:\\gaurav\\gaurav.txt")

# Click on Submit Button
webDriver.find_element_by_xpath("//input[@value='Submit']").click()

#This will close the browser
webDriver.quit()

Extracting Links from Web Page

Click here to get Java Snippet for this script.

__author__ = 'Gaurav.Khanna'

from selenium import webdriver

# Initializing FireFox Driver
webDriver = webdriver.Firefox()

# Open URL
webDriver.get("http://not-just-a-tester.blogspot.in/")

# Find all anchor tags
allLinks = webDriver.find_elements_by_tag_name("a")

# Print All Links
for links in allLinks:
    print(links.get_attribute('href'))
    print("\n")

# Close Browser
webDriver.close()