Wednesday, September 5, 2012

How to capture your applications screenshot to a Word document

'This method capture the desktop Screen capture.
Desktop.CaptureBitmap "C:\TempSS.png",true

'If you want to capture your application, then use syntax like B().CaptureBitmap

Set objWord=createobject("Word.Application")
objWord.Documents.Open("C:\Test.doc")
objWord.Application.Selection.InlineShapes.AddPicture("C:\TempSS.png")
objWord.ActiveDocument.Save
'objWord.ActiveDocument.SaveAs("1.doc")
objWord.ActiveDocument.Close
Set objWord=nothing

How to reverse a string without using any built-in function

As per the question/requirement you should not use any built-in methods like mid, instr etc.

We can reverse the string using the regular expression.

Find the script below:

'The below script prints the input string in reverse order without using any built-in methods

str="Hello Uday"

Set regExpObj=new RegExp
regExpObj.pattern="[a-z A-Z]"
regExpObj.global=true

Set matches=regExpObj.execute(str)
For each letter in matches
    result=letter.value&result
Next

print result

The above code prints "yadU olleH"

Actually i got this code from one netizen, but i didnt understand the logic when i look at it. Then i started nailing down the logic.

Here is how it goes:
The regular expression "[ ]" stands for matches one character in a list at a time, so [a-z A-Z] bring only one character from "a-z" or "A-Z".



So upon executing this regular expression did you see there are 10 characters(length of the string).

So in the next for loop we are iterating through these 10 characters from 1-10.

Because we are appending the the new character to the result, the first char will become last and second character becomes last but one and so on.

At the end of the loop, you will get the reversed string.

I hope you will be clear now.


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.   

  

Saturday, July 28, 2012

What are main challenges in automation

Test Estimations
Measuring the complexity: Complexity derived from manual test cases, complexity of steps will be more complex in automation that manual steps(estimation based on manual steps)
Test data creations
Turn around time: for clarifications while automating(lack of knowledge in each and every step), Dependency on manual tester/developer
Rework: you might think some scripts/functions developed by colleagues will be useful, but when you script scenarios they might not be as per your requirement.
Monitoring the automation work as per the plan


Technical Issues
Technical support: Delay in technical support from the tool support team/lack of proper forums to communicate if any issue arises
Third party/Custom controls:
Object/Application changes: some object properties changes on the fly,
Tool limitations: limitations of installing extra softwares in client machines when there is work around with other softwares, tool bugs/patches
Compatibility: compatibility of tool, cross browser testing, cross platforms (win xp, win 7)
Intermittent application errors: You may see these in unstable environments

Lack of choosing rightframework
Choosing right framework: Each framework have advantages and disadvantages. We should foresee the expectation/changes and adopt a suitable framework.
Framework changes: When necessary change framework, which should not impact already developed scripts.

Lack of identifying suitable resources(human resources): unavailability of resources

Lack of process in identifying automatable test scenarios.
Rather than automating workflow/end-end flow including micro level test scenarios are not good for automation like when a dialog is opened, verify dialog title, click ok, cancel, short cut key etcc....
Here the intent should be maximum coverage with scripting.

Choosing the right tool for automation.

How to navigate back to previous page

When we work on a web application, user clicked on a link/button etc and how the user traverse back to previous page.

Browser(objBrowser).back will not traverse back to previous page.

We can use SendKeys with backspace method.

Set oWShell=createobject("WScript.Shell")
oWShell.SendKeys "{BS}"

browser(objBrowser).Page(objPage).Link(objLink).Click
browser(objBrowser).Page(objPage).sync
browser(objBrowser).Back ' Here back works well with Firefox but not with IE