Custom View Options for QTP’s Expert-View Editor

by Anshoo Arora ON October 1, 2009 · Posted In All, QTP · 15 comments

Today, after being quite tired of switching windows between Notepad++ and QTP, I started experimenting with different layouts I can create to make the the QuickTest editor a little more viewing-friendly. After a few minutes of playing around, I finally have something that I like.

I wanted to share what I have with you guys, and I hope if you have custom layouts for QTP’s editor, please feel free to share them.

My Custom Settings for QTP's Editor - View Options

The Layout elements can be accessed from the following menu:

Tools -> View Options -> Fonts and Colors

Values for each element to create the layout in the snapshot:

Font name: Consolas

Size: 9

Elements:
	Comment: (Foreground: Green) (Background: White) (Style: Italic)
	Default: (Foreground: Black) (Background: White) (Style: Normal)
	Left Margin: (Foreground: Black) (Background: Silver) (Style: Normal)
	Number: (Foreground: Red) (Background: White) (Style: Bold)
	Operator: (Foreground: Black) (Background: White) (Style: Bold)
	Reserved Word: (Foreground: Navy) (Background: White) (Style: Bold)
	Selected Text: (Foreground: White) (Background: Navy) (Style: Normal)
	String: (Foreground: Maroon) (Background: White) (Style: Normal)

Subscribe to Relevant Codes (by Anshoo Arora)

Hello! We're always posting interesting articles on Relevant Codes. Why not subscribe so you don't miss out?

Leave a Comment

{ 15 comments… read them below or add one }

baxou087 May 10, 2011 at 11:04 am

Thank you so much for this post.
You saved my eyes and brain from atrocious suffering

Reply

Anonymous September 23, 2010 at 8:13 pm

Great suggestion however, I would change the font to Verdana with size 10. More legible to me.

Reply

Vivek September 17, 2010 at 1:54 am

Hey Anshoo,
Ive been trying for quite some time now and still not been able to make my formatting changes persistent on QTP10. Everytime i restart QTP the formatting is reset. Wondering if you have come across this issue.

Reply

Anshoo Arora September 29, 2010 at 2:56 pm

Vivek,

Yes, I’ve come across this issue with QTP 9.2. It was due to some security setting on the machine which removed all the changes we made during a session. Whenever we restarted the machine, all the changes made in the previous session with all software would be reset.

Reply

Anonymous June 11, 2010 at 9:16 am

I had an issue copying a vbbeautifier code to my qtp editor…………after setting fonts and colors i can be able to view well formatted script in my qtp editor

Thankyou for your help
God Bless U

Reply

Anshoo Arora June 22, 2010 at 10:19 am

Great!! :)

I generally use Notepad++ and VBSEdit otherwise – both great tools, but VBSEdit offers IntelliSense which can be quite helpful if you have a lot of code in your libraries.

Reply

Janavi April 16, 2010 at 6:14 pm

Could you please tell me how exactly can i use the code you have mentioned above to change the font color using descriptive program
ps: i have never used Class

Reply

Anshoo Arora April 17, 2010 at 10:53 am

Janavi, this will be done manually through Tools -> View Options -> Fonts and Colors. No is required code for this :)

Reply

Pragya October 12, 2009 at 12:53 am

What a great reply :) Thanks Anshoo… because of this 0 height i am not able to see the invisible text box but QTP has found.. Thank you again!!

Reply

Anshoo Arora October 12, 2009 at 5:38 pm

Thank you! :)

Reply

Pragya October 4, 2009 at 12:23 am

Anshoo,

I have a new question for you.

We all know that Google webpage has a single text box right? Then why is dis code failing?

Browser(“micclass:=Browser”).Page(“micclass:=Page”).WebEdit(“micclass:=WebEdit”).Click

Its giving an error that there are multiple objects matching my description which is not present to the naked eye. So what I did is, I modified the code to:

Browser(“micclass:=Browser”).Page(“micclass:=Page”).WebEdit(“micclass:=WebEdit”,”index:=0″).Highlight
This code doesnt do anything. It simply shifts my mouse focus to Internet Explorer.

But the following code:
Browser(“micclass:=Browser”).Page(“micclass:=Page”).WebEdit(“micclass:=WebEdit”,”index:=1″).Highlight
highlights the search text box in Google page.

Any suggestions?

Pragya

Reply

Anshoo Arora October 4, 2009 at 10:30 am

Hi Pragya,

Great question! Actually, there is only one of the WEbEdits that is visible to the human eye. If you examine the HTML Source of the page, or use ChildObjects, you will see that there are actually 2 of them. The reason why you do not see the other is because the developers of Google’s Home Page have made the height property of one of the WebEdits to 0. Since the height is 0, its impossible for the human eye to find it.

You can run the code below to retrieve all the properties of both WebEdits:

Dim oDesc, colObject, x

Set oDesc = Description.Create
oDesc("micclass").Value = "WebEdit"

Set colObject = Browser("title:=Google").Page("micclass:=Page").ChildObjects(oDesc)

For x = 0 to colObject.Count - 1
	With colObject(x)
		Print "Class Name: "     & .GetROProperty("micclass")
		Print "abs_x: "          & .GetROProperty("abs_x")
		Print "abs_y: "          & .GetROProperty("abs_y")
		Print "class: "          & .GetROProperty("class")
		Print "default value: "  & .GetROProperty("default value")
		Print "disabled: "       & .GetROProperty("disabled")
		Print "height: "         & .GetROProperty("height")
		Print "html id: "        & .GetROProperty("html id")
		Print "html tag: "       & .GetROProperty("html tag")
		Print "kind: "           & .GetROProperty("kind")
		Print "max length: "     & .GetROProperty("max length")
		Print "name: "           & .GetROProperty("name")
		Print "outerhtml: "      & .GetROProperty("outerhtml")
		Print "x: "              & .GetROProperty("x")
		Print ": "               & .GetROProperty("y")
		Print "-------------------------------------------------"
	End with
Next

I hope this helps.

:)

Reply

Anonymous April 18, 2010 at 4:54 pm

Anshoo, Thanks for your response, I understand we can edit it manually by navigating to View Options Dialog.
My question is can we do the same using vbscript.. for example we can change the run settings like App.Test.Settings.Run.StartIteration = 1…similarly is there a way change the font settings.

Thanks

Reply

Anshoo Arora June 22, 2010 at 10:09 am

I don’t think its possible through AOM.. But, you bring an excellent point. It may be possible through another technique. Research goes on :)

Reply

Vivek September 30, 2010 at 3:01 am

yeh.. actually i got this resolved by gettin my id power user access. thanks for the reply anyways :)

Reply

Previous post:

Next post: