Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

First Steps in Selenium IDE - Understanding Selenium: Questions and Answers

In one of the previous blog, we explained in brief how Selenium IDE looks and the features Selenium IDE provides. In this post, we discuss on creating first test in Selenium IDE, adding assertions and verify statements, difference between assert and verify statements, storing value of an element at run time, adding comments to the test. 
In upcoming posts, I will cover on advance features in Selenium IDE and also include how to create test suites and details of useful commands in Selenium IDE


Before proceeding further, we must have Mozilla Firefox with Selenium IDE Add-on installed. Selenium IDE Add-on can be installed from Selenium official website.  Let us start now for creating first test in Selenium IDE.

Question 1: What are the points to be considered before starting automation on Selenium IDE?

Answer:  Below are some of points to be considered before starting with Automation on Selenium IDE.
  •      Test should have known start point for the workflow.
  •           Test should be independent of other test and complete in itself
  •      Test should clean up itself. This means Page should return to initial state on completion.

Question 2: Please explain how to create a new test in Selenium IDE?

Answer:  Creating first test in Selenium IDE:
Let us assume, we want to record on Google Page using Selenium IDE, We will open Firefox and selenium IDE and record on Google Page, by searching for ‘test’. Below are the steps stored in the test for action performed on Google Page? We can save the test and play it back.

First Test in Selenium IDE

Question 3: What is the difference between verify and assert statement in Selenium

Answer: Adding Validation and Assertion to test:
When we record and playback in Selenium IDE, we perform the actions on object in workflow, i.e. launching the URL, setting value test in edit box and clicking on submit. Now we need to verify if the title of the Page is correct or particular object is visible in the Page.
Difference between Assert and verify is while test stops in case of assert fails but remaining statements in the test are executed in case of verify statement even if the verify statement fails.
We know the difference between verify and assert but do not know how to add assertion in a test in Selenium. Assertions are not added during recording but needs to be added manually to enhance the test.
To add an assert in the page, right click on the object as shown below. In the Google Page, I click on edit box and right click. On clicking, I get following options as shown below. Once I click on an option, it is displayed in the Selenium IDE test as shown below. In this manner we can add different assertions, verify, wait, and store statements in the test.


Adding assert and verify statements in test

Question 4: What is the need of comments in script and how to insert comments in script in Selenium IDE?

Answer: For better understanding of the script, we need to add comments in the test flow.  This can be done as explained in screenshot below:


Adding a comment in Selenium IDE
Adding a comment in Selenium IDE

Question 5: How can we store the value of an element in Selenium IDE and use it further in the test flow?

Answer: we can store the text of an element using StoreText Command; Target will be the object whose text we need to store and value will be the variable whose value needs to be stored.
We can use the variable as ${stroredValue} where storedValue is the variable in which value was stored.

Index page for QA Automation and QTP

Below are the useful navigation links for this website and helps user know how to navigate through various topics on this posts are available on this blog

Automation Concepts in QTP

Software Testing Tutorial

Descriptive Programming and Document Object Model in QTP

Working With Objects

Working with Database


Working With Actions 


Working with Automation Object Model

Working with Test Data

QTP Tutorials

Descriptive programming in QTP: Questions Answers

This post discusses on concepts of descriptive programming in QTP through questions and answers. Difference between DP and OR, types of DP, various examples are explained in this article


Question  1: What is descriptive Programming?

Answer: Descriptive programming allows working on an object by describing properties of the object at run time. Descriptive Programming provides flexibility to select properties. For e.g.: Suppose we have Web Object, we can use only html Id if defined for the object and some other properties if html id is not defined such that description of object is unique.

Question 2:  What are different types in which descriptive programming can be implemented?

Answer: Descriptive programming can be implemented using string based description or object based description:
               a.  String based Description
               b.  Using Description Object

Question 3: What is String based Description approach for descriptive programming?

Answer: In String based description, we create a description string similar to the tree structure we get on recording in QTP. So what we do is replace the tree structure with description string:


e.g:  Browser(“Google”).Page(“Google”).WebEdit(“q”).set “nitin” 
In Case of Object Repository(Recording) is expressed in Descriptive Programming as :Browser(“name:=Google”).Page(“name:=Google”).WebEdit(“html id:=qq”,”index:=0”).Set “nitin”

Note: We can have parent object defined using OR and child object using DP, but vice versa is not possible, i.e Parent object description using DP and child object using OR.
Browser(“Google”).Page(“Google”).WebEdit(“html id:=qq”,”index:=0”).Set “nitin” is correct but
Browser(“name:=Google”).Page(“Google”).WebEdit(“html id:=qq”,”index:=0”).Set “nitin” is incorrect

Question 4: How is Descriptive programming implemented using description object?

Answer:  Using description object, we create description object and add properties to the object


e.g: Set objdesc = description.create
objdesc(“name”).value =”google”
Browser(Objdesc).Close
Or
Set objdesc = description.create
objdesc(“name”).value =”search”
Browser("Google").Page("title:=.*").WebButton(objdesc)

Question 5: I want to know number of links in a page, how Can I found the same using description object

Answer: Code to find number of links in a page is:
Set objLink=Description.Create ‘’Create a description object
objLink("html tag").value="A"    ‘’Now the description object will refer to collection of object with tagName as “A”
set olnk=Browser("Google").Page("Google").ChildObjects(objLink) ‘’Collection of all links in page(“Google”)
iCount = olnk.Count ‘’Count of all links in the page.
MsgBox “Count of links in Page are” & iCount
Similar to number of link, we can find number of Editbox (tagname as Input), Image(Img) and so on in a page

Question 6: I want to know, if certain object exist in a page and create a generic function to verify object of various types, How to code for this?

Answer: Function below can be used to create a common function to verify existence of various types of objects in the page:
Call Func_IsExistsObject(“Html id>abcd”,”WebEdit”,)
Public Function Func_IsExistsObject(strobjDescObj,strObjType,)
On error resume next
Func_IsExistsObject = "False"  ‘’ Set the flag as ‘False’ at start of test execution
Set objDesc= Description.create ‘’create  description  object
strobjDesc = split(strobjDescObj,">")
objdesc(strobjDesc(0)).value = strobjDesc(1)
objdesc("index").value = 0
If(ucase(strObjType) = "WEBBUTTON") Then
Func_IsExistsObject = Browser("Google").Page("title:=.*").WebButton(objdesc).Exist
ElseIf(ucase(strObjType) = "IMAGE") Then
Func_IsExistsObject = Browser("Google").Page("title:=.*").Image(objdesc).Exist
ElseIf(ucase(strObjType) = "CHECKBOX") then
Func_IsExistsObject = Browser("Google").Page("title:=.*").WebCheckBox(objdesc).Exist
ElseIf(ucase(strObjType) = "PAGE") then
Func_IsExistsObject = Browser("Google").Page(objdesc).Exist
ElseIf(ucase(strObjType) = "WEBELEMENT") then
Func_IsExistsObject = Browser("Google").Page("title:=.*").WebElement(objdesc).Exist
ElseIf(ucase(strObjType) = "WEBTABLE") then
Func_IsExistsObject = Browser("Google").Page("title:=.*").WebTable(objdesc).Exist
ElseIf(ucase(strObjType) = "WEBLIST") Then
Func_IsExistsObject = Browser("Google").Page("title:=.*").WebList(objdesc).Exist
ElseIf(ucase(strObjType) = "WEBEDIT") Then
Func_IsExistsObject = Browser("Google").Page("title:=.*").WebEdit(objdesc).Exist
ElseIf(ucase(strObjType) = "LINK") then
Func_IsExistsObject = Browser("Google").Page("title:=.*").Link(objdesc).Exist
End If
Exit Function

Question 7: How to close all browsers except QC using descriptive programming?

Answer:  Below lines of code can be used to close all browsers except QC using descriptive programming:
Set oBrowser = Description.Create
oBrowser("micclass").Value = "Browser"
Set ColBrowser= Desktop.Childobjects(oBrowser)
For i = 0 to CollBrowser.count -1 step 1
                If Instr(CollBrowser (i).GetROProperty("Name"), "Quality Center") = 0 Then
                                CollBrowser(i).Close
                End If
Next

Question 8: What are the advantage and disadvantage of descriptive Programming compared to Object Repository?

Answer: Using Descriptive Programming helps in Portability and helps to identify object in case of dynamic object or creating objective library of description objects in case application is not developed completely but we know the properties of objects. For further details of comparison of Object Repository , Refer to  below links: