Showing posts with label Testing Interview Questions. Show all posts
Showing posts with label Testing Interview Questions. Show all posts

Sunday, February 3, 2013

How to select more than one item from a Listbox using QTP

We can select more than one value from any list objects like JavaList, WinList, WebList, WpfList object ect.. by using "ExtendSelect" method.

The script would like below:
If the items are selected based on Item Names,
B( ).P( ).WL( ).select "Item Name1"
B( ).P( ).WL( ).extendselect "Item Name2"

If the items are selected based on Index, then
B( ).P( ).WL( ).extendselect "#2"

How to find all the selected items from a List object
B( ).P( ).WL( "Technology").select "Java"
B( ).P( ).WL( "Technology").ExtendSelect ".NET"
B( ).P( ).WL( "Technology").ExtendSelect "Testing"

sSelectedItems=B( ).P( ).WL( "Technology").GetROProperty("selection")
 print sSelectedItems

which prints selected items as
Jave;.NET;Testing

Saturday, February 2, 2013

Can virtual objects be definied using Descriptive Programming


Can virtual objects be defined using Descriptive Programming and also can we get the properties of Virtual Objects?

Overview of Virtual Objects:
Virtual Objects are objects in the application which behave like Standard objects but cannot be recognized by QTP.
So using Virtual Object Manager, we can map this Virtual Object to a Standard Class(based on its behavior) and its boundaries and can assign to a standard object(Parent).
By using Virtual Objects, you need to make sure that the application window should be at the same position and same size when you record and run your tests.

So come back to our question, can we define virtual objects using descriptive programming?
Answer is "Yes"
But we need to define x,y,width and height properties to define the virtual object.
It looks like something below:
window("Paint").WinObject("NetUIHWND").virtualobject("x:=256","y:=66","width:=22","height:=20").highlight
window("Paint").WinObject("NetUIHWND").virtualobject("x:=256","y:=66","width:=22","height:=20").Click 13,11

But how can we get these coordinates?
In a new QTP Test, add the virtual object and just record an action in the virtual object.
Once you get those coordinates write a script like above.
You can also these is "v" label added to the virtual object(see the attachment).


2nd Question: Can we get the properties of those virtual objects?
 Answer: Yes
If the virtual object is added to the Object Repository(OR), then you can use the GetTOProperty to retrieve whatever properties associated in the OR. You cannot get any values of the properties which are not in OR. So from the above screenshot, you can get only x, y, width, height and name property values only.

Friday, February 1, 2013

How to retrieve a string which have all types of alphabets and special characters

Say i have a string like "asasd^(&^*&skmw(_^_iolma%(&(%"

From the above string how to extract only alphabets?

The below code helps to retrieve/extract only alphabets from the input string
str="asasd^(&^*&skmw(_^_iolma%(&(%"

Set r=new regexp
r.pattern="[a-z A-Z]"
r.global=true
set s=r.execute(str)
'For each letter in s
'result= letter.value&result
'Next
For i=s.count -1 to 0 step -1
    Set oVal=s.item(i)
    result=oVal.value&result
next
print result

Now how to retrieve only special characters from the above string?

We can retrieve/extract by either of the below regular expressions.

str="asasd^(&^*&skmw(_^_iolma%(&(%"
Set r=new regexp
r.pattern="[^a-z A-Z]"
'r.pattern="\W"
r.global=true
set s=r.execute(str)
'For each letter in s
'result= letter.value&result
'Next
For i=s.count -1 to 0 step -1
    Set oVal=s.item(i)
    result=oVal.value&result
next
print result

Monday, August 6, 2012

What is Web Event Configuration in QTP

QTP has an option to configure Web Event Configuration.
By default, QTP records all click events.
We can configure other events like onmouserover, onfocus, onchange etc...
If we configure all other events for an object the script is not readable. So we need to configure as per our needs.
The changes will be incorporated after changing the settings. Previous generated scripts dont have any impact.

To configure web events navigate to Tools -> Web Event Configuration.
Here we can choose levels/settings required for recording events.



One of the example here is
User has to enter some value in a textbox, then the button beside it will be activated. For this, there is a back end even "onmouseup". So to click on that button, we need to fire that event like below:

B().P().WE().fireevent "onmouseup"
B().P().WB().click



Using web event configuration, we can configure only the web&HTML Objects. For other objects, we need to update the environment specific XML Configuration files.

What are the difference between Delete and Truncate in Sql Server

Following are few differences.

1.
Truncate is a DDL Command.
Delete is a DML Command.


2.
Truncate operation cannot be rolled back.
Delete operation can be rolled back.

3.
By using Truncate operation, it deletes everything and reconstructs the table structure (schema). We can’t retain the values.
By using Delete we can retain the deleted values.

4.
We cannot use where clause in truncate.
Where clause can be used with Delete.

5.
By using Truncate operation, all the identities will be deleted.
By using Delete identities cannot be deleted.

6.

The syntax for truncating a table is:
            truncate table tablename

The syntax for deleting rows from a table is:
      delete from table or
 delete from table where condition

7. 
Truncate table is faster and uses fewer system and transaction log resources than Delete.
The Delete statement removes rows one at a time and records an entry in the transaction log for each deleted row.

8.
Because Truncate table is not logged, it cannot activate a trigger.
It can activate a trigger.