Sunday 13 October 2013

Software testing interview questions for 1/2/3 years of experience

 Welcome  - On this page, you will find all advanced software testing interview questions for experienced candidates (1/2/3/4 years).

All the questions listed below are frequently asked in software companies like TCS, Cognizant, Infosys, HCL, IBM, Wipro, Syntel, Capgemini, Amdocs.
 

1. What is fault masking?
Fault masking means presence of one defect will hide the presence of another defect in the system.

2. What is exploratory testing?
Exploratory testing is a type of experience based testing.In exploratory testing, we test the software starting with basic functionalities and then
using the information about the system, we try to test more functions of the system. In short we explore the system as we move ahead with the testing.

3. How do we prepare test plan?
IEEE 829 specifies what attributes are there in test plan.

4. What are the different stakeholders in testing process?
Every testing project has below stakeholders.
Developers
Testers
End Users
System Owners
QA and Development Managers

5. What is configuration management wrt software testing?
Configuration management is used to manage the changes done to the test artifacts.
Every testartifact is stored in the configuration management software like SVN.  We can access all the versions of the same document.
We can also track who made what changes in which document and when.

6. What are different software testing metrics?
Software testing has below metrics.
Code Coverage
Cyclomatic Complexity
etc.


7. How to do test estimations?
Test estimations are carried out to give better picture of how much human effort will require to test the software and the cost of the project.
Based upon the scope of the testing project, we estimate the effort required to test the system.

8. What is orthogonal testing? Explain with example.
Orthogonal testing is used to test the application with only few test input values from given set of inputs.
Exhaustive testing with all permutation and combinations of input values is not possible. So orthogonal testing helps us to reduce the test input domain values.

9. What is error / mistake?
Error is a human action that produces incorrect result.

10. What is defect(bug/fault)?
A flaw in the system that can cause the system to fail to perform its required function.
If the code containing defect is executed, software failure occurs.
Cost of finding and fixing the defect increases over time so you must try to find out the defects as early as possible in SDLC.

11. What is exhaustive testing?
It is a type of testing in which we try to test the software with all possible input values and preconditions.

12. What are different software testing pronciples?

There are few testing principles that every tester must know as mentioned below.
Testing shows that there are defects but it does not prove that there are no defect. This means that even after we test the software, we can have defects still present in the system
Exhaustive testing is not possible. Many systems are very complex. So testing such systems with all possible input values is not possible.
Testing should be started as early as possible because the cost of finding and fixing the defect increases over time.
Small number of modules contain most of the defects in the system. So we must focus on those error prone modules while testing the system
Pesticide paradox - If same tests are run again and again, they will no longer find any defects in the system. So you must always try to change the test cases, input values so that you will be able to find new uncovered defects.
Software testing is context dependant. Every system should be tested in different way as Some systems are life critical while some are very simple systems. So the objectives and priorities of the testing are different for every system.
Absence of error fallacy : - If there are no errors in the system, it does not mean that system is good  if end user is not able to use the system easily and it meets its requirements.

13. What is COTS?
COTS stands for the commercial off the shelf software. This kind of software is developed for large number of customers is delivered to many customers across the world.
For example - chrome browser.

14. What are the different software testing models?
WaterFall Model.
Increamental Development Model - RAD, RUP, Agile (extreme programing)
V-Model

15. What are software testing levels?

1. Unit testing              - done by developers
2.Component Testing    - done by developers
2. Integration testing     - stubs, drivers
3. System testing         - functional , non-functional
4. User Acceptance testing - Alpha and Beta testing

16. What are software testing methods?
There are 2 methods of software testing.

1. Static - review, walkthrough, inspection, data flow, control flow
2. Dynamic testing - white box(structure based/glass box), black box (Specification based), expereince based

Below is the list of white box testing methods.
1. Statement coverage
2. Decision Coverage
3. Condition Coverage

Below is the list of black box testing methods.
1. Equivalance partitioning
2. Boundry Value Analysis
3. Decision Tables
4. State Transition Diagrams
5. Use Case Testing  - ATM Example.

Below is the list of experience based methods.
1. Error Guessing
2. Exploratory Testing


17. Explain below IEEE 829 specifications - Test design, Test case, Test Plan, Test log, Incident Report , Defect Report , Test summary report.
IEEE 829 is a standard for creating test artifacts. Each test document has specific attributes.
For example - Test Plan has below parameters/attributes.


  • Test Plan Identifier
  • Introduction
  • Test Items
  • Features to Test
  • Features not to Test
  • Approach
  • Item pass/fail criteria
  • Suspension/Resumption Criteria
  • Test Deliverables
  • Test Tasks
  • Environment Needs
  • Responsibilities
  • Staffing and training needs
  • Schedule
  • Risks
  • Approvals


18. What is probe effect?
Effect on the system when it is being measured.

19. What are different tools that can be used in testing process?
We can use software tools in almost every phase of software testing lifecycle. Quality center is the one which is very useful.
We can have requirements management tool that helps in recording of requirements and requirements traceability.
Defect management tool is used to record and track incidents and defects.
Configuration management tools are used to control the changes in  test artifacts.
Review tools helpus in test review process of documents, codes.
Test execution tools (QTP, Selenium) are used to record  and playback the automated operation in application.
Dynamic analysis tools are used to get the runtime information of the state of the software code which can be used to identify the
unassigned pointers, memory allocation, memory leaks.
Performance testing tools (LoadRunner, Jmeter) are used to measure how the system behaves when there are more users actively using the system or there is large volume of data.
Load testing - More users, More transactions
Volume testing - Large volume of data
Stress Testing - testing the system beyond its specified hardware/software requirements.
Debugging tools(Microsoft debugger) are used to find and remove the cause of the failure in the system.

20. Explain different software testing metrics like defect density, cyclomatic complexity, code coverage, statement coverage, decision coverage etc.

code coverage = no of coverage items exercised/total number of coverage items * 100
code coverage finds out which part of the code has been executed by the test suite.
Statement coverage = no of statements exercised/ total number of statements * 100
Decision coverage = no of decision outcomes exercised / total number of decision outcomes * 100
Cyclomatic complexity = no of branches in the code + 1

21. Explain defect/incident lifecycle.
Whenever new incident occurs in the system, we create a new incident to track it.
Each incident follows typical lifecycle.
When it is confirmed that defect is a valid then we assign it to the developer and it's status becomes assigned.
Then developer will fix the issue and status of the incident will be marked as fixed.
Then again testers will retest the system to verify that the defect is really removed from the system.
If defect is removed from the system, status of that defect/incident is marked as closed otherwise status of the defect becomes reopened.


22. What is test condition?
Test condition is an item in the system that could be verified by one or more test cases.

23. What is test case?
A set of input values, execution preconditions, expected results, execution postcondition is called as a test case.

24. What is test Oracle?
Test oracle is a source to determine the expected results to compare with actual result.

You can visit QTP Master page to learn QTP.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Software testing interview questions and answers for freshers

When you appear for the QTP interview or selenium interview, you may be asked some common software testing interview questions.

In below paragraph, you will find frequently asked software testing interview questions and their answers asked in different software companies like TCS, cognizant(cts), Tech Mahindra, Infosys, Wipro, TCS, Syntel, Capgemini, Cybage, Amdocs, IBM etc.

1.What is software testing?
Software testing is the process of validating and verifying the software product.
Objective of the software testing is to check that software under test meets the requirements in System Requirements Specification (SRS) and the
expectations of the end users.
Software testing gives the information about the quality of the software.
There are different software testing lifecycle models based upon the SDLC like waterfall, agile, extreme, incremental etc

2. What are software testing types?

Every testing activity that Test team does will have a specific objective. Based upon this objective we can categorize the testing as mentioned below.

Installation testing     - Testing done to check that software system can be installed on the desired platform seamlessly.
Compatibility testing  - Testing which checks that system is compatible with different hardware and software products.
Smoke testing           - Most critical test cases are selected and run to check that important modules of the system work or not.
Sanity Testing           - Testing few test cases from every module to determine if it is ok to proceed with further testing.
Regression testing     - Testing the system to verify that the fixes done by the developers are working as expected and there are no new defectd induced
Acceptance testing   - Testing done from end user perspective
Alpha testing            - Alpha testing is actual testing by developers/potential users/customers/ an independent test team at the developers' site
Beta testing             - Beta testing is done by acutal customers at their own location or site. Developers are not involved.
Functional Testing    - We test the feature or functionality of the system
Non-functional testing - We test scalability, performance and security of the system.
Destructive testing       -Testing used to cause the system to fail. It checks the robustness of the system when invalid inputs are given.
Software performance testing -Testing used to check the system stability and scalability under many  transactions with large volume of data
Usability testing          - Testing is used to test the ease of use from end user perspective.
Accessibility testing    - Testing to check if users with some disabilities can access the system easily
Security testing          -  Testing used to test how secure the system is. We also try to find out any vulnarabilities in the system.
Internationalization and localization - Testing to check if system is working as expected in different geographic settings.




3. Explain software testing lifecycle?

1.Requirements analysis
2.Test planning: Test strategy, test plan, testbed creation.
3.Test design and development: Test scenarios, test cases, test datasets and automated test scripts are created in this phase.
4.Test execution: Manual and automated execution of test cases is carried out.
5.Bug logging: Defects are logged.Development team decides which defects should be fixed, rejected etc After defects are fixed, testers again try to retest the defect and again reopen the defect if it is not really fixed.
6.Test Reporting :Test metrics and summary reports are generated.
7.Test Closure :Testing ends when the exit criteria is met and learnings from testing could be used as a reference for new software projects.

4. What is the difference between manual testing and automation testing?
Manual testing involves testing of the software without any automation software. Human effort is required to execute the test cases.
In automation testing we use software tools like QTP, selenium to automate the test execution process.
In manual testing we need manual efforts while in automation testing initial efforts are required to develop the automation script. In regression execution, we can use
automation testing to execute the test cases day and night without manual intervention.

5. What is automation testing?

Automation testing is nothing but use of softwares ( like QTP, Selenium)  to test the application under test.
Automation testing helps minimise the manual effort. It saves efforts and cost to execute the test cases.
Advantages of automation testing-
It helps in reduction of testing execution time
Human Efforts are also saved
It is accurate in calculating the output values.
Overall it helps in reduction of cost of testing.

6. What is black box testing ?
Black box testing is also called as specification based testing. Black box testing is a testing in which we don't know internal details like code structure of the software.
We give the input to the system and verify the output produced by system. We don't worry how the system calculates the output as long as system is giving correct output.
Here is the list of black box testing methods.
Equivalance partitioning
Boundry Value Analysis
State transition Diagrams
Decision Tables
Orthogonal Array Testing
Use Case Testing

7. What is white box testing?
Unlike black box testing, in white box testing we know the internal details like code, algorithms of the software.
We try to test the internal structure is working as expected. This is generally done by the developers of the software.
In white box testing, we find out below test metrics.

code coverage = no of coverage items exercised/total number of coverage items * 100
code coverage finds out which part of the code has been executed by the test suite.
Statement coverage = no of statements exercised/ total number of statements * 100
Decision coverage = no of decision outcomes exercised / total number of decision outcomes * 100
Cyclomatic complexity = no of branches in the code + 1

8. What is grey box testing?

Grey box testing is a combination of black box testing and white box testing.

9. What is the difference between static and dynamic testing?
In static testing, We try to find the defect in the system without executing the software. For example, review of the code by peers, Finding the cyclomatic complexity
of the code.Static testing involves code review, walkthrough, inspection, data flow, control flow of the system

In dynamic testing, we execute the software. We provide some input and verify the output. So we can find the run time errors in dynamic testing
Dynamic testing involves white box(structure based/glass box), black box (Specification based), expereince based testing.


10. Explain unit testing.
Unit testing is done by the developers of the software. Testers are not involved in unit testing. Unit testing is the method in which smallest part of the system are tested.
Usually smallest part of the system is function or procedure or class methods in object oriented programming.
Stubs may be created for the unit testing the code.

Almost all programming languages have unit testing frameworks that are used by the developers to test thier code.
For example - Junit is a unit testing framework in Java.


11. Explain Integration testing.
Integration testing is generally done after unit testing. After the small modules have been tested, they are grouped together to form the system.
Integration testing is used to verify that different modules have been integrated seamlessly and there is no defect while integrating the modules/components.
The objective of the integration testing is that all the modules/components are interacting with each other correctly.
Types of integration testing are :-
1. Top-down     -> Top level integrated modules are grouped together and sub-system is tested.
2. Bottom-up    -> Bottom level integrated modules are grouped together first and sub-system is tested.
3. Big Bang      -> In Big Bang approach, all modules are integrated together and then testing is done.


12. Explain System testing.
System testing is done after integration testing. This is used to verify that system works as expected and meets the expected requirements.
System testing is a black box testing.

Here is the list of types of system testing.
Functional Testing
Performance testing - Load testing, Volume testing, Stress testing, Scalability testing
Compatibility testing
Security testing
Sanity testing and Smoke testing
Exploratory testing
Ad hoc testing
Regression testing
Installation testing
Maintenance testing
Recovery testing.
Accessibility testing
Usability testing


13. What is the difference between functional testing and non-functional testing?
Functional testing means testing the software to verify that software adheres to the functional requirements.
While non-function testing involves other aspects of the software like accessibility, usability and performance testing.

14. What is security testing?
Security testing means testing the software from security perspective. It verifies that the system complies to the security standards and
there are no loopholes in the system.

15. Explain usability testing.
Usablity testing is used to test ease of use of the software.

16. Explain performance testing.
Performace testing includes load testing, volume testing and stress testing.

17. Explain exhaustive testing with example.
Exhaustive testing means testing the software with all possible permutation and combination of the input.

18. What are different software testing tools in market?
We can have different software as mentioned below to test the softwares.
QC
QTP
bugzilla
Test Track
Test Complete
Test Studio
Jira
Loadrunner
Winrunner

19. What are the automation testing tools in the market?
Here is the list of automation testing tools in the market.
QTP
Selenium
Test Complete


20. What is Quality Center and what are the different modules in it?
Quality center is a test management software from HP. It involves below modules.
Requirements
Test Plan
Test Lab
Defects

21. What is selenium?
Selenium is an open source web application testing tool. Selenium provides APIs in different languages like .net, java, python, perl, ruby etc.
We can test websites on different web browsers like Internet explorer, firefox, chrome, safari using selenium.

22. What is the differnece between selenium and QTP?
QTP is functional automation testing tool that can be used to test applications developed in variuos platforms like .net, Java, peoplesoft etc.
It is not a open source software.It is the most popular automation testing tool in the industry as of now.

Selenium is an open source web application testing tool. Selenium provides APIs in different languages like .net, java, python, perl, ruby etc.
We can test websites on different web browsers like Internet explorer, firefox, chrome, safari using selenium.



23. What are the different software testing artifacts?
Here is the list of common testing artifacts.
Test cases
Test execution report
Defect report
Incident report
Test Plan.
Test Summary Reports

24. Explain software defect and software failure.
Software defect is an unwanted condition in the software which when executed may result in the system failure.

25. What is the difference between test case and test script?
Test case is detailed stepwise description of how we can verify the requirement manually.
Test script is the automated version of manual test case.

26. What do you mean by dynamic program analysis?
Dynamic programming analysis means testing the program while executing it.Dynamic program analysis helps in understanding time and space complexity of the program. We can also find memory leaks in the program while executing the program.

27. What is Pair testing?
Pair testing is a testing type in which 2 team members work together to test the application.

28. What is high priority defect?
High priority defect is the defect which must be fixed as soon as possible.

29. What is high severity defect?
High severity defect is the defect which can cause huge loss if it is available in the system.

30. What is the difference between re-testing and regression testing?
Re-testing is used to check that defect is really removed after developers fixed it.
While regression testing is used to check that post-modification of software, no new defects were induced in the system.

31. What is boundry value analysis?
Developers tend to make mistakes while designing the code to check boundry conditions.
Boundry value analysis can be used to find the defects found at the boundry values.

Example - Consider education grading system.
If student scores more than 75%, his grade is distinction while if he scores between 60% and 75%, his grade is first class.
In this scenario, we test the software using boundry values like 59,60,61,74,75,76 to check that software provides correct output.

32. When should we stop testing?
Below is the list of factors that help us determine when we should stop testing.
For every testing project, we have the exit criteria.
We execute the all the test cases that test all requirements of the system.
We try to find the the defects in the system.
When we have a confidence about the quality of the software, then we may stop the testing.
All stakeholders in the testing project must give green signal to stop the testing.
We have also time and budget constraints so we focus on the most important functionalities of the software.

33. What is test coverage?
Testing is done to check that all our functionalities are working as expected or not.
Test coverage is the metric that gives us idea about how many functionalities have been tested
Test coverage can have below types.
Code Coverage
Decision Coverage
Functionality Coverage

************************************************************************
Please note that if you are staying in USA, UK or Australia, and searching for a testing job there, above testing questions and answers will help you crack the interview.

You can visit QTP Master page to learn QTP.
Please give your inputs, suggestions, feedback to Us about above Software testing topic. We value your thoughts.If you want to ask any question, you can comment it below.

Friday 11 October 2013

What is previousSibling, nextSibling in QTP?


Well - let me tell you that  all the properties (previousSibling, nextSibling ) are not defined by QTP.

All these properties are HTML DOM properties that help us get the elements at the same level of the given element in web page.

You can access these method in QTP using .object property which lets you access native methods and properties of the objects/elements.

Example - 

<body>
<div id="parentdiv">
 This text is inside div element of which id is - parentdiv

<div id="fc">
 This is nested div1
</div>


<div id="sc">
 This is nested div2.
</div>


</div>
</body>

As you can see in above example, 2 div elements ( fc, sc) are inside the div(parentdiv).
So for fc-div and sc-div, parentdiv is the parent element. While for parentdiv, fc-div and sc-div are child div elements. The div elements fc-div and sc-div are siblings of each other as both are at same level.
sc-div is the nextSibling of the fc-div. While fc-div is the previousSibling of the sc-div.


You can get access to these elements using HTML DOM properties nextSibling, previousSibling properties

For example -
'access the next sibling of fc-div
set obj= Browser("myb").Page("myp").object.getElementById("fc")
print obj.nextSibling.innerText

'access the previous Sibling of sc-div
set obj= Browser("myb").Page("myp").object.getElementById("sc")
print obj.previousSibling.innerText

This is how we can access the elements using  previousSibling, nextSibling in QTP.

You may find below links very useful
  1. http://qtp-interview-questions.blogspot.in/2013/06/how-to-use-html-dom-in-qtp.html
  2. http://qtp-interview-questions.blogspot.in/2013/10/what-is-previoussibling-nextsibling-in.html
  3. http://qtp-interview-questions.blogspot.in/2013/10/what-is-parentnode-childnodes.html
  4. http://qtp-interview-questions.blogspot.in/2013/10/what-is-getelementsbytagname-in-qtp.html
  5. http://qtp-interview-questions.blogspot.in/2013/10/how-to-use-getelementbyid-in-qtp.html
  6. http://qtp-interview-questions.blogspot.in/2013/10/how-to-get-innertext-of-webelement-in.html

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

What is parentNode, childNodes, firstChild, lastChild in QTP?

Well - let me tell you that  all the properties (parentNode, childNodes, firstChild, lastChild) are not defined by QTP.

All these properties are HTML DOM properties that help us get the child and parent element of the given element in web page.

You can access these method in QTP using .object property which lets you access native methods and properties of the objects/elements.

Example - 

<body>
<div id="parentdiv">
 This text is inside div element of which id is - parentdiv

<div id="fc">
 This is nested div1
</div>


<div id="sc">
 This is nested div2.
</div>


</div>
</body>

As you can see in above example, 2 div elements ( fc, sc) are inside the div(parentdiv).
So for fc-div and sc-div, parentdiv is the parent element. While for parentdiv, fc-div and sc-div are child div elements.

You can get access to these elements using HTML DOM properties parentNode, childNodes, firstChild, lastChild.

For example -
'access the child objects
set divParentObject= Browser("myb").Page("myp").object.getElementById("parentdiv")
print divParentObject.firstChild.innerText
print divParentObject.lastChild.innerText

set allchilds = divParentObject.childNodes
for i=0 to allchilds.length-1
 print allchilds(i).innerText
next

'access the parent element of div with id "fc"
set childObject = Browser("myb").Page("myp").object.getElementById("fc")

print childObject.parentNode.innerText 

This is how we can access the elements using parentNode, childNodes, firstChild, lastChild in QTP.

  1. http://qtp-interview-questions.blogspot.in/2013/06/how-to-use-html-dom-in-qtp.html
  2. http://qtp-interview-questions.blogspot.in/2013/10/what-is-previoussibling-nextsibling-in.html
  3. http://qtp-interview-questions.blogspot.in/2013/10/what-is-parentnode-childnodes.html
  4. http://qtp-interview-questions.blogspot.in/2013/10/what-is-getelementsbytagname-in-qtp.html
  5. http://qtp-interview-questions.blogspot.in/2013/10/how-to-use-getelementbyid-in-qtp.html
  6. http://qtp-interview-questions.blogspot.in/2013/10/how-to-get-innertext-of-webelement-in.html

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
If you have any queries, you can drop the comment below. 

What is getElementsByTagName in QTP?

If you are testing web application, you may have used getElementsByTagName method to get access to all elements that have given tag.

Please note that this is not QTP's own method but it is native HTML DOM method.

getElementsByTagName takes one parameter as an input which should be the tag of the element like td, tr, span, div etc.
This method returns the collection of elements that have the given tagname. 

Example.

<body>
<div id="head">
 This text is inside div element of which id is - head
</div>

<div>
 This is another div
</div>

<div>
 This is div number 3.
</div>

</body>

In above example, we have sample html document body in which there are 3 div elements.

To get the text value inside all these div elements, we can use the innertext method as mentioned below.

set tn = Browser("myb").Page("myp").object.getElementsByTagName("DIV")
for i=0 to tn.length-1
   'print the innertext of each div element here
    print tn(i).innerText
next


Thus basically we use  getElementsByTagName method to get all element objects with given tag name.

Please note that we can also get the data inside hidden elements using this method. QTP can not read data inside hidden elements.


  1. http://qtp-interview-questions.blogspot.in/2013/06/how-to-use-html-dom-in-qtp.html
  2. http://qtp-interview-questions.blogspot.in/2013/10/what-is-previoussibling-nextsibling-in.html
  3. http://qtp-interview-questions.blogspot.in/2013/10/what-is-parentnode-childnodes.html
  4. http://qtp-interview-questions.blogspot.in/2013/10/what-is-getelementsbytagname-in-qtp.html
  5. http://qtp-interview-questions.blogspot.in/2013/10/how-to-use-getelementbyid-in-qtp.html
  6. http://qtp-interview-questions.blogspot.in/2013/10/how-to-get-innertext-of-webelement-in.html

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to use getElementById in QTP?

I know that you have come on this page because you are testing the web application.
Web application testing is very interesting stuff.

Apart from normal web methods and  properties provided by QTP, you can use lot of native methods of the web elements.

One of such native method of the document object is  getElementById.
This method takes one parameter as an input which should be the id of the element.

Example.

<body>
<div id="head">
 This text is inside div element of which id is - head
</div>
</body>

In above example, we have sample html document body in which there is one div element with id = 'head' and it contains some text.

To get the value inside this div element, we can use the innertext method as mentioned below.

print Browser("myb").Page("myp").object.getElementById("head").innerText

So output of above code will be.

"This text is inside div element of which id is - head"

Thus basically we use  getElementById method to get the element object and then we can use its innerText method to get the data inside that element.

Please note that we can also get the data inside hidden elements using this method. QTP can not read data inside hidden elements.

You can find all concepts on QTP (UFT) on Master Page.
This is how we can use html dom in qtp to get the information displayed on the webpage. This makes the web application testing quite easy stuff.
  1. http://qtp-interview-questions.blogspot.in/2013/06/how-to-use-html-dom-in-qtp.html
  2. http://qtp-interview-questions.blogspot.in/2013/10/what-is-previoussibling-nextsibling-in.html
  3. http://qtp-interview-questions.blogspot.in/2013/10/what-is-parentnode-childnodes.html
  4. http://qtp-interview-questions.blogspot.in/2013/10/what-is-getelementsbytagname-in-qtp.html
  5. http://qtp-interview-questions.blogspot.in/2013/10/how-to-use-getelementbyid-in-qtp.html
  6. http://qtp-interview-questions.blogspot.in/2013/10/how-to-get-innertext-of-webelement-in.html
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to get innerText of webelement in QTP?

In my 10 years of experience in QTP,  I have worked on many web applications that involved jquery, ajax and rich controls.

To test such applications we must have good understanding of the HTML DOM concept.
Extracting the values from the web elements on the page is very common thing that we do in QTP.

To get the inner text or inner html of the web elements, we can use below syntax.

Example -

print browser("bb").page("xys").Object.getElementById("pqr").innerText


Please note that we should use the .object after property before we use html dom.

In above example I am trying to get the text displayed inside web element of which id is "pqr"

We can use more such methods as mentioned below to get access to the web elements on the page
1. getElementById()   - get the element by id
2. getElementsByTagName() - get all elements with given tag name
3. getElementsByClassName() - (does not work in < ie9) - get all elements having given class
4. getAttribute() - get the value of attribute of given node
5. getAttributeNode() - get the attribute node
6. hasAttribute()  - check if a node has given attribute
7. hasChildNodes()  - check of node has any children
8. item() - access the node based on the index from the collection

Once we get the element object, we can use below properties to get the data.
1. innerHTML – gets the html code inside element
2. innerText  - gets the text value inside element
3. getAttribute – gets the value of attribute
4. nodeName  - (like TD, SPAN, #text, #document, Attribute name)
5. nodeType   - (Element, Text, Attribute, Comment, Document)
6. nodeValue  - (attribute Value)
7. childNodes   - gets all child elements of the given node
8. attributes   - gets the collection of all attributes of given node
9. className   - gets the name of class of given element
10. firstChild    - gets the access to first child element of the given node.
11. Id – gets the id of the given node.
12. lastChild – gets the last child element of the given node
13. nextSibling – gets the next element at the same level as given node.
14. offsetLeft
15. offsetTop
16. previousSibling - – gets the previous  element at the same level as given node.
17. parentNode –gets the parent node of the given node
18. scrollLeft
19. scrollTop
20. scrollWidth
21. style   - gets the style information of the given node
22. tagName – gets the name of the tag of given node
23. textContent – gets the text displayed inside given node
24. title  - gets the title of the given node
25. length – gets the total number of nodes in the collection.

You can find all concepts on QTP (UFT) on Master Page.
This is how we can use html dom in qtp to get the information displayed on the webpage. This makes the web application testing quite easy stuff.
  1. http://qtp-interview-questions.blogspot.in/2013/06/how-to-use-html-dom-in-qtp.html
  2. http://qtp-interview-questions.blogspot.in/2013/10/what-is-previoussibling-nextsibling-in.html
  3. http://qtp-interview-questions.blogspot.in/2013/10/what-is-parentnode-childnodes.html
  4. http://qtp-interview-questions.blogspot.in/2013/10/what-is-getelementsbytagname-in-qtp.html
  5. http://qtp-interview-questions.blogspot.in/2013/10/how-to-use-getelementbyid-in-qtp.html
  6. http://qtp-interview-questions.blogspot.in/2013/10/how-to-get-innertext-of-webelement-in.html
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Friday 4 October 2013

How to see associated library files in QTP using script?

We can iterate all library files attached to test in QTP using below code.

Set qtpApp = CreateObject("QuickTest.Application")
qtpApp.Launch
qtpApp.Visible = True


Set qtLibraries = qtpApp.Test.Settings.Resources.Libraries
' Get the libraries collection object

For each l in qtLibraries
                'here we are printing the names of all library files associated with this test.
                 print l
Next

We can also associate the library file to test at runtime using below code
   qtLibraries.Add "C:\book.vbs"
' Add the library file viz. book.vbs to the collection.

We can also check if given file is associated with the test using below code.

If qtLibraries.Find("C:\myfile.vbs") = -1 Then
    print "library file not found"
 else
    print "library file found"
End If

'Save the test
qtpApp.Test.Save
qtpApp.Quit

 ' Quit QuickTest

Set qtLibraries = Nothing
Set qtpApp = Nothing

This is how we can work with QTP libraries.


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to read a value from the cell in datatable sheet in QTP?

Reading a value from the cell in a sheet from datatable is a 2 step process.

  1. In first step we set the row pointer
  2. In second step we specify the parameter/column name from the sheet to read

Example ->

'In Below example, we have set the row pointer to 2 in transaction sheet
datatable.GetSheet("Transactions").SetCurrentRow(2)

'in below code we have specified that we want to read a value from the Module_Name column from the 'transactions sheet
print datatable.Value ("Module_Name","Transactions")

This is how we can read values from the datatable in QTP.

You may find below links very useful if you want to know more about data tables in QTP.

  1. How to export datatable sheets to excel
  2. How to import excel-sheet to datatable
  3. How to read value from cell in datatable in QTP
  4. Explain setcurrentrow method in qtp
  5. Datatable object in qtp
  6. How to export datatable to excel in qtp
  7. How to get current sheet from datatable
  8. How to check if parameter exists in sheet in datatable in qtp
  9. Explain dtsheet object in qtp
  10. What are the utility objects in qtp


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to import excel sheet to datatable in qtp

When we design a test automation framework in qtp, we usually store the test data inside excel sheets.
Sometimes we need to load the test data in datatable to execute the test cases.

We can either import all excel sheets from excel workbook or we can import particular excel sheet from the the workbook to the datatable

'to import all sheets from excel file, use below  line of code
datatable.Import "c:\abc.xls"


'to import  single sheet from excel file, use below  line of code
'here we are importing the sheet global from abc.xls into testdata sheet in datatable in QTP.
datatable.AddSheet "testdata"
datatable.ImportSheet "c:\abc.xls","Global","testdata"


You may find below links very useful if you want to know more about data tables in QTP.
  1. How to export datatable sheets to excel
  2. How to import excel-sheet to datatable
  3. How to read value from cell in datatable in QTP
  4. Explain setcurrentrow method in qtp
  5. Datatable object in qtp
  6. How to export datatable to excel in qtp
  7. How to get current sheet from datatable
  8. How to check if parameter exists in sheet in datatable in qtp
  9. Explain dtsheet object in qtp
  10. What are the utility objects in qtp

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

How to export the datatable sheets to excel sheet in QTP?

Working with datatable is very common in QTP.
We use datatables to store the runtime data.

The biggest disadvantage of datatable is that it is a temporary storage which means that data stored in datatable is removed when test execution is over.

If you want to reserve the datatable data, you can export the data to excel sheet so that you can use it later on.

Examples -


'Add some data to global sheet in datatable
datatable.GlobalSheet.AddParameter "p1","v"
datatable("p1") = "abc"

'Export complete datatable - This will export all sheets from the datatable
datatable.Export("c:\abc.xls")

'export only particular sheet from the datatable to excel sheet
'after below code is executed, sheet with name global will be exported to excel sheet in kk.xls
datatable.ExportSheet "c:\kk.xls","Global"

You may find below links very useful if you want to know more about data tables in QTP.
  1. How to export datatable sheets to excel
  2. How to import excel-sheet to datatable
  3. How to read value from cell in datatable in QTP
  4. Explain setcurrentrow method in qtp
  5. Datatable object in qtp
  6. How to export datatable to excel in qtp
  7. How to get current sheet from datatable
  8. How to check if parameter exists in sheet in datatable in qtp
  9. Explain dtsheet object in qtp
  10. What are the utility objects in qtp


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Wednesday 2 October 2013

Explain setCurrentRow method in QTP

In QTP, we have a datatable that can be used to store the runtime data from application or test data.
In datatable we have multiple sheets as mentioned below.
  1. GlobalSheet - can be accessed from any action.
  2. LocalSheet per Action - can be accessed from specific sheet only.
  3. Any user defined sheet. 
To add data into any sheet, you have to first get access to the sheet
By default globalsheet is refered.

To get reference to the any other sheet use below syntax
datatable.GetSheet("sheetname")

Examples of Datatable in QTP - 

'to add new sheet to datatable, you can use below method
datatable.AddSheet("sagar")


'to add parameter to the sheet
datatable.GetSheet("sagar").addParameter "id",1
'in above statement, we have added parameter with name id to sheet called sagar. 1 is the value added into first row of that parameter

'to set the row pointer we can use setCurrentRow method
datatable.GetSheet("sagar").setCurrentRow(1)
'Above statement will set row pointer to first row in sheet name sagar.

'to access data from the sheet, use below statement.
datatable("id","sagar") = "ppp:"
'above code will store ppp: in the sagar-sheet and under id column/parameter

'to move to next row, use below method.
'datatable.GetSheet("sagar").SetNextRow
datatable.GetSheet("sagar").setCurrentRow(2)
datatable("id","sagar") = "1"

'datatable.GetSheet("sagar").SetNextRow
'Please remember that You can only set a next  row that contains at least one value.
datatable.GetSheet("sagar").setCurrentRow(3)
datatable("id","sagar") = "112"

datatable.GetSheet("sagar").setCurrentRow(1)



for i=1 to 3
msgbox datatable("id","sagar")
datatable.GetSheet("sagar").SetNextRow
next

'to get the total number of rows in any sheet we can use.
datatable.GetSheet("sagar").getRowCount


You may find below links very useful if you want to know more about data tables in QTP.
  1. How to export datatable sheets to excel
  2. How to import excel-sheet to datatable
  3. How to read value from cell in datatable in QTP
  4. Explain setcurrentrow method in qtp
  5. Datatable object in qtp
  6. How to export datatable to excel in qtp
  7. How to get current sheet from datatable
  8. How to check if parameter exists in sheet in datatable in qtp
  9. Explain dtsheet object in qtp
  10. What are the utility objects in qtp


Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.