Relevant Codes (by Anshoo Arora)

A Test Development Resource for HP QuickTest Professional.

Descriptive Programming (DP) Concepts – 2 (Regular Expressions)

by Anshoo Arora on August 10, 2009

A wildcard character can be used to substitute for any other character or characters in a string.1 This means, we can use a wildcard to make our descriptions more generic. For example, if the property ‘file name’ of an Image is ‘getAllAttributes.JPG’, we can use a wildcard several ways:

' Only using the first 2 words: getAll
Browser( "title:=MyTitle" ).Page( "title:=MyTitle" ).Image( "file name:=getAll.*" ).Click
' Using 1 word (Attributes) with the extension (JPG)
Browser( "title:=MyTitle" ).Page( "title:=MyTitle" ).Image( "file name:=.*Attributes.*JPG" ).Click

Let’s put this technique into practice. Let’s use Mercury Tours for this test. Let’s try to identify the banner image (banner2.gif) having the following text embed: ‘one cool summer ARUBA’.

This image is the property of http://newtours.demoaut.com (HP/Mercury)

This image is the property of http://newtours.demoaut.com (HP/Mercury)

Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner2.gif").Highlight
 
Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner2.*").Highlight
 
Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner.*").Highlight
 
Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=ban.*gif").Highlight
 
Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=ban.*f").Highlight

Ofcourse, there are more ways to identify the banner image, but I’ve only used the above 5. Similarly, we can use this wildcard character for the Browser and Page objects:

' Without wildcard(s): 0.20 seconds
Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner2.gif").Click
 
' With wildcard(s): 0.30 seconds
Browser("title:=Welcome.*").Page("title:=.*Mercury Tours").Image("file name:=banner2.gif").Highlight   
 
' 0.28 seconds
Browser("title:=Welcome:.*").Page("title:=Welcome.*").Image("file name:=banner2.*").Highlight          
 
' 0.56 seconds
Browser("title:=.*Mercury Tours").Page("title:=.*: Mercury.*").Image("file name:=banner.*").Highlight  
 
' 0.61 seconds
Browser("title:=.*Mercury Tour.*").Page("title:=Welcome:.*").Image("file name:=ban.*gif").Highlight    
 
' 0.51 seconds
Browser("title:=.*: Mercury.*").Page("title:=.*Mercury Tour.*").Image("file name:=ban.*f").Highlight

You might notice a little drop in performance for some of the above statements. This is quite obvious though. Using a real world example:

Scenario 1
If you were asked to deliver a letter to John and you had the following piece of information provided: Building 184, Floor 5, Room 120, Desk 9. You would know that you first have to find Building A, then take an elevator to the 5th floor, find Room 120, and once you’re inside room 120, John sits on Desk # 9. This is quite straight-forward and ofcourse you’ll be able to quickly find John.

Scenario 2
In another scenario, if you were asked to deliver a letter to John who is in Building 184 and on the 5th floor, how would you find John? You would have to go to each room and ask for John, and make sure it is the correct John before delivering the letter to him. This might take longer.

This is roughly what happens in our scripts. As our descriptions get more and more generic, the time it takes to identify the object increases. Therefore, even though wildcard characters can simplify our work, we should be a little careful how we use them.

Regular-Expressions.Info is a good source to learn regular-expressions. We will now do the exact same test we did about with Banner2.gif, but this time using some more regex style characters.

' Using the first few characters of the title and the first few characters of the image
Browser("title:=Welc\w+\D+\w+").Page("title:=Welc\w+\D+\w+").Image("file name:=ban\w+\d+\.\w+").Highlight
 
' Using the last few characters of the title with first and last characters of the image
Browser("title:=\w+\D+\w+ours").Page("title:=\w+\D+\w+ours").Image("file name:=b\w+2\.gif").Highlight
 
' Same as above for Browser and Page, but '...' for image
Browser("title:=\w+\D+\w+ours").Page("title:=\w+\D+\w+ours").Image("file name:=b\w+2\....").Highlight
 
' Same as above, but replaced 'b' with a '.'
Browser("title:=\w+\D+\w+ours").Page("title:=\w+\D+\w+ours").Image("file name:=.\w+2\....").Highlight

In the proceeding article we will cover Ordinal Identifiers and also see how to create a simple test module for a login process.

Descriptive Programming Series

  1. Descriptive Programming (DP) Concepts – 1
  2. Descriptive Programming (DP) Concepts – 2 {Regular Expressions}
  3. Descriptive Programming (DP) Concepts – 3 {Ordinal Identifiers}
  4. Descriptive Programming (DP) – 4 {Creating a Test Script)

References

  1. Wildcard Character, Wikipedia
  2. QuickTest Professional Help

If you have any questions, please ask them in the comments section. If your query is confidential, please use the Contact Form to send me an e-mail instead.

{ 58 comments… read them below or add one }

1 QTP User January 18, 2010 at 1:24 pm

Hi Anshoo,
I came across this site while looking for using a regex for a Select property of Weblist. Its wonderful. Hoping you could give me a solution to my issue.
ex: weblist is populated with “green”, “blue”, “orange”, “white” etc. My select should work something similar to “gre.*”. Is it possible?
Browser (“blah”).Page(“blah”).weblist(“blah”).Select (regex)

I tried different ways to be able to use a regex for the select property. More than assigning the value to the weblist, the challenge was to get the selection visible. Would be greatly appreciated if you could provide a solution to this.

Thanks in advance,
QTPUser

Reply

2 Anshoo Arora January 18, 2010 at 1:32 pm

Sure is possible, my friend.

Public Function RegexSelect(ByVal Object, ByVal sItem)
	Dim sAllItems, arrAllItems, ix

	RegexSelect = False

	sAllItems = Object.GetROProperty("all items")
	arrAllItems = Split(sAllItems, ";")

	For ix = LBound(arrAllItems) To UBound(arrAllItems)
		If InStr(1, LCase(arrAllItems(ix)), LCase(sItem)) > 0 Then
			Object.Select arrAllItems(ix)
			RegexSelect = True : Exit Function
		End If
	Next

End Function
RegisterUserFunc "WebList", "RegexSelect", "RegexSelect"

If you have the following values:

Green
Blue
Orange
White

and you would like to select Green, the code would be any of following four statements:

Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "gre"
Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "G"
Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "een"
Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "gree"

I hope this helps.

3 QTP User January 18, 2010 at 1:41 pm

Hi Anshoo,
Appreciate your quick response. Thats how I did aswell since I couldn’t use regex. My list had 1000′s of items. Performance is poor when I did something like this… splitting into array and looping thru’ the array. I was looking forward to use inbuilt functions to increase the performance. Could you suggest me an alternative approach.

Thanks much
QTP User

Reply

4 Anshoo Arora January 18, 2010 at 2:25 pm

It is definitely possible through RegExp. I am going to try it and post the solution soon.

5 Anshoo Arora January 18, 2010 at 2:42 pm

There you go:

Public Function RegexSelect(ByVal Object, ByVal sItem)
	Dim sAllItems, oRegExp, oMatches

	sAllItems = Object.GetROProperty("all items")

	Set oRegExp = New RegExp
	oRegExp.IgnoreCase = True
	oRegExp.Pattern = ";" & sItem & ";"
	Set oMatches = oRegExp.Execute(sAllItems)

	If Not oMatches.Count > 0 Then
		oRegExp.Pattern = ";" & sItem
		Set oMatches = oRegExp.Execute(sAllItems)
	End If

	If Not oMatches.Count > 0 Then
		oRegExp.Pattern = sItem & ";"
		Set oMatches = oRegExp.Execute(sAllItems)
	End If

	If oMatches.Count > 0 Then
		sMatch = oMatches(0)
		sMatch = Replace(Mid(sMatch, InStrRev(sMatch, ";", Len(sMatch) - 1), Len(sMatch)), ";", "")
		Object.Select "" & sMatch
	End If
End Function

If you have the following values:

Green
Blue
Orange
White

and you would like to select Green, the code would be any of following four statements:

Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "gre.*"
Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "G.*"
Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect ".*een"
Browser (“blah”).Page(“blah”).weblist(“blah”).RegexSelect "gree.*"

6 QTP User January 18, 2010 at 6:32 pm

Thanks for the solution Anshoo. Admire your determination.

- QTP User

Reply

7 Anshoo Arora January 20, 2010 at 9:14 am

Most welcome. I have created another version of this function and will publish it in the coming few weeks citing your original comment there :)

8 Puneet Varma January 22, 2010 at 10:34 am

Hi Anshoo,

I am trying to get the checkpoint to recgonize the different username when a new is added. The message will indicated the following: “The user ‘provider33′ has been successfully added.’

SwfWindow(“HA – You are currently”).SwfWindow(“Add User”).Dialog(“ePDHA – [Acknowledgement]“).Activate
SwfWindow(“HA – You are currently”).SwfWindow(“Add User”).Dialog(“HA – [Acknowledgement]“).Static(“The user ‘provider2′ has”).Check CheckPoint(“The user ‘provider.*’ has been successfully added.”)
SwfWindow(“HA – You are currently”).SwfWindow(“Add User”).Dialog(“ePDHA – [Acknowledgement]“).WinButton(“OK”).Click

Reply

9 Anshoo Arora January 24, 2010 at 11:38 pm

Hi Puneet,

You will have to modify the CheckPoint properties to be able to insert the regular expression. Adding a regular expression to the description of the CheckPoint will not suffice here.

10 Puneet February 22, 2010 at 1:39 pm

Hi Anshoo,

Below is a script where I have taken the SSN_Verify and stored in the external file and now i am taking the GetROProperty from the innertext below and adding it to the ActualResult which works fine, but I cannot seem to figure is how I can go through the mutliple lines to verify the actual ssn have been imported through the system. I have mutlple ssn in the webpage so I want to go through each line and verify the SSN based on the SSN_Verify .

Datatable.Import(“C:\Temp\Data.xls”)
DataTable(“ActualResult”, dtLocalSheet) = Browser(“HA :: Web Portal_3″).Page(“HA :: Web Portal”).WebElement(“First Name”).GetROProperty(“innertext”)
ActualResult = Datatable(“ActualResult”, dtLocalSheet)
ActualResult = SSN_Verify
If SSN_Verify = ActualResult Then
Reporter.ReportEvent micPass,”Verify SSN”, “The expected result ” & ActualResult & “is correct”
else
Reporter.ReportEvent micFail,”Verify SSN”,”The expected result ” & ActualResult & “is incorrect”
End If
Datatable.Export(“C:\Temp\Data.xls”)

Thanks
Puneet

Reply

11 Anshoo Arora February 24, 2010 at 8:26 am

Puneet,

Is the data that you are trying to retrieve from your application inside a WebTable? If that is the case, you can traverse through the cells where the data is stored and use the .GetCellData method to retrieve it each time your loop increments.

12 Puneet February 22, 2010 at 1:48 pm

Based on the previous question how can I make the innertext wildcard right now in the OR the innertext is set to a specific SSN.

Reply

13 Anshoo Arora February 24, 2010 at 8:28 am

It depends, actually. If the SSN are stored inside a WebTable, then you would not need to use OR at all, as it can be done very easily through DP and VBScript. Can you e-mail me the HTML source of the page you’re working on to anshoo [dot] arora @ relevantcodes.com without spaces. I can take a look at it for you and suggest a few snippets that you can use in your testing.

14 Puneet February 22, 2010 at 2:39 pm

How can I get each value verified in the WbfGrid?

Thanks

Reply

15 Anshoo Arora February 28, 2010 at 5:41 pm

Hi Puneet,

I have not had a chance to work with the WbfGrid object, so can’t help you there :(

16 Puneet February 25, 2010 at 12:23 am

I have a problem with ComboBox. Whenever I run the QTP script CombBox wil select the first value in the list before selecting the actual value I want, but then each value in the combBox has a sub value. The problem I am having is that when is select the first value in the CombBox, the sub value will be stuck in there and will not change the list to the values I selected.
For example:
First value in the list is combo1 selected and its sub value in a different combobox is 1, 2, 3, 4
Second value in the list is selected combo2 and the sub value in a different combobox is 5,6,7,8

Having said when QTP is running it will select the first one then it will select the second (which is I want) but then the sub value is stuck under 1.,2,3,4 instead actually going to the values 5,6,7,8 once QTP select the second value.

Hopefully, you understand the situation.

Thanks
Puneet

Reply

17 Anshoo Arora February 28, 2010 at 6:08 pm

Puneet,

What is the code that you’re currently using for this scenario? I guess we can make it quite generic to fit your requirement.

18 Marco March 18, 2010 at 12:20 am

Hi Ashoo

I have problem selecting from a Weblist.

ex: My Database Contains “Green”, “Blue”, “Orange”, and “White” and My Weblist contains “Green (123)”, “Blue (321)”, “Orange (-)”, and White (2345).

C = DataTable.Value(“COLOR”, “Action1 [Dbscript]“) ‘C = “Green”
I store the Green value in C variable

The problem is Green is not part of the Weblist, How will I select Green (123)?
note: the number after Green may change in every execution.

Respectfully Yours,
Marco

Reply

19 Marco March 18, 2010 at 12:25 am

Sorry for the mispelled Anshoo.

20 Anshoo Arora March 18, 2010 at 1:30 pm

Hi Marco,

Please see if this comment helps you resolve this issue: http://relevantcodes.com/descriptive-programming-dp-concepts-2-regular-expressions/#comment-1898

If not, please use the comments section of this post for your reply and we’ll try to find an alternate solution.

21 Marco March 18, 2010 at 7:47 pm

Hi Anshoo,

Since I daclare the value “Green” to C (C = “Green”) how will I select “C” in a Weblist?
Where the value in the Weblist is “Green (123)”?

It does not recognize “Green” in the Weblist, because the value in the Weblist is “Green (123)”.

I tried using this code:

Browser("blah").Page("blah").WebList("blah").Select ""&C&".*"
Browser("blah").Page("blah").WebList("blah").Select ""&C&.*""
Browser("blah").Page("blah").WebList("blah").Select "&C.*"
Browser("blah").Page("blah").WebList("blah").Select C.*

But all these codes does not work.

about
http://relevantcodes.com/descriptive-programming-dp-concepts-2-regular-expressions/#comment-1898
How will I execute “Public Function RegexSelect(ByVal Object, ByVal sItem)”?
do i need to call RegexSelect Function()?
is there any values I need to pass for “(ByVal Object, ByVal sItem)”?

Respectfully Yours,

Reply

22 Anshoo Arora March 18, 2010 at 9:53 pm

The first thing we need to do is to load the function in our library and associate the library with our test. The following code goes in your library:

Public Function RegexSelect(ByVal Object, ByVal sItem)
	Dim sAllItems, oRegExp, oMatches

	sAllItems = Object.GetROProperty("all items")

	Set oRegExp = New RegExp
	oRegExp.IgnoreCase = True
	oRegExp.Pattern = ";" & sItem & ";"
	Set oMatches = oRegExp.Execute(sAllItems)

	If Not oMatches.Count > 0 Then
		oRegExp.Pattern = ";" & sItem
		Set oMatches = oRegExp.Execute(sAllItems)
	End If

	If Not oMatches.Count > 0 Then
		oRegExp.Pattern = sItem & ";"
		Set oMatches = oRegExp.Execute(sAllItems)
	End If

	If oMatches.Count > 0 Then
		sMatch = oMatches(0)
		sMatch = Replace(Mid(sMatch, InStrRev(sMatch, ";", Len(sMatch) - 1), Len(sMatch)), ";", "")
		Object.Select "" & sMatch
	End If
End Function

RegisterUserFunc "WebList", "RegexSelect", "RegexSelect"

Once the above is done, next, you can use the following code in your test:

Browser("blah").Page("blah").WebList("blah").RegexSelect C & ".*"

23 Sai123 March 25, 2010 at 11:26 pm

Hi Anshoo,
Need a help in writing a function
### My code ###

k = objectproperties(pageheading,"Yahoo")    --**  yahoo is in double Quotes
pageheading_exist = browser(XXX).page(XXX).webedit(k).Exist
if pageheading_exist = "True" then
    Report Pass...

###My Function###
Public Function objectproperties(x,y)
    set x = Description.create
    x("visible") = "True"
    x("outertext") = y

'**** My Problem is how to return the value of this x(which consists of object properties) for this function
End Function

Please advice.
Thanks,
Sai

Reply

24 Anshoo Arora March 28, 2010 at 11:21 pm

If you would like to return the x description object, you can do this:

Public Function objectproperties(x,y)
    set x = Description.create
    x(“visible”) = “True”
    x(“outertext”) = y

    Set objectproperties = x
End Function

25 Sai March 29, 2010 at 12:13 pm

Thankyou Anshoo.. i will let you knowthe Results after testing it..

Reply

26 Sai March 29, 2010 at 12:18 pm

One moreQuestion from my end.Please suggest
I have to capture one value from the dropdown list my dropdown list will have values like
XXXXX $ XX – XXXX

i need to capture the value after $ and need it to assign it to an variable so that i can work on it.
Please advice how to do it using Regular Expressions

Thanks,
Sai

Reply

27 Anshoo Arora March 29, 2010 at 1:52 pm

Considering yours is a Web application, you can do this:

Function IsRegExMatch(ByVal sText, ByVal sPattern)
	Dim RegEx

	Set RegEx = New RegExp
	RegEx.Pattern = sPattern
	RegEx.IgnoreCase = True
	IsRegExMatch = RegEx.Test(sText)
End Function
allItems = Browser("").Page("").WebList("").GetROProperty("all items")
arrAllItems = Split(allItems, ";")

For ix = LBound(arrAllItems) To UBound(arrAllItems)
    If IsRegExMatch(arrAllItems(ix), "^.{5} \$ .{2} – .{4}") Then
        sVar = arrAllItems(ix)
    End If
Next

sVar = Trim(Split(sVar, "$")(1))

MsgBox sVar

28 Narasimha June 15, 2010 at 3:45 am

Hi Anshoo,

I am using descriptive programming for a particular functionality. I came across the below scenario and not able to proceed further.

The scenario is like, when I click a particular tab in my application, it is opening a fresh page and the page title is “title:=Financial Details–Encounter Date/Time-14/06/2010 16:55″. The data and time changes are the system date and time. My question is whether it is possible to manage the date and time using Regular expression. If so, can you please help me out with the solution.

Reply

29 Satya June 17, 2010 at 2:08 am

Yes it’s quite possible.
use this Description for ur page title-
“title:=Financial Details–Encounter Date/Time-.*″

30 Anshoo Arora June 22, 2010 at 12:15 pm

Thanks Satya :)

31 chaits June 24, 2010 at 8:22 am

Hello Anshoo!!

Relly Good stuff yaar…I have a question for you. I have a web edit box of type multi line. Now I need to enter two names in that. I need to set the first name in first line and the second name needs to be entered in the next line. Second name should not be entered in the first line. Do you have any answers for me. (Need to enter 10 names in 10 different lines of a web edit box of type multi line).

Thanks!!

Reply

32 Anshoo Arora June 28, 2010 at 10:35 am

You can use vbNewLine to insert names in different lines:

Browser("").Page("").WebEdit("").Set "John" & vbNewLine & "Smith"

33 ranjith July 26, 2010 at 7:36 am

Hi Anoshoo Arora

my question “ranjith123″ this will be go for Regular Expressions

Reply

34 uday July 26, 2010 at 10:23 am

Hi,

Scenario:
I have a form whose title is “form: New” on launching and after filling in the fields upon saving the form, the title becomes
“form: name” where name is text field which I have entered in the form, so how do i regex this title, and I have the object in the
OR whose name and title are the same “form” New”,
so soon after saving this the line of code
Browser(“title:=form: New”).Page(“title:= form: New”).any method is not working can u please give me the suggestion in this

thanks in advance
Uday

Reply

35 Anshoo Arora July 30, 2010 at 8:47 am

Uday,

You can use the following regex: form: \D+. In your QTP code, you can use the following:

Browser("title:=form: \D+").Page("title:= form: \D+").

36 Anonymous August 9, 2010 at 6:11 am

Dear Anshoo,

Hope you are doing great! I appreciate the effort you had taken and share your knowledge with us.
My application is SAP and the requirement is to enter a value into the text box which present in SAPGrid. So my code is like this,

SAPGuiSession( ).SAPGuiWindow( ).SAPGuiGrid( ).SetCellData 1, “Selection Value”, DataTable(“Broker_Report, dtLocalSheet)

The problem is here that the code puts the value correctly in to the textbox and we could see the value in the application. But, the application says that there is no value in the text box. So, I manually copied the value and pasted into the textbox. Now, the application recognizes the value. Could you please help me how do I set the value to the text box which would be recognized by the application?

Reply

37 Sivaram S August 9, 2010 at 7:05 am

Dear Anshoo,

Hope you are doing great! I appreciate the effort you had taken and share your knowledge with us.
My application is SAP and the requirement is to enter a value into the text box which present in SAPGrid. So my code is like this,

SAPGuiSession( ).SAPGuiWindow( ).SAPGuiGrid( ).SetCellData 1, “Selection Value”, DataTable(“Broker_Report, dtLocalSheet)

The problem is here that the code puts the value correctly in to the textbox and we could see the value in the application. But, the application says that there is no value in the text box. So, I manually copied the value and pasted into the textbox. Now, the application recognizes the value. Could you please help me how do I set the value to the text box which would be recognized by the application?

Thanks,
Sivaram S

Reply

38 Anshoo Arora August 9, 2010 at 9:05 am

Sivaram,

I haven’t had a chance to work with SAP controls in relation to QTP. But, this is quite a similar issue to what we see in Web apps when custom controls are implemented. Have you tried using SendKeys to set values, or DeviceReplay?

39 Uday Kumar Sangu August 11, 2010 at 6:29 am

Hi Sivaram,

I did work on the SAP application using QTP earlier……………for very short time though,

May be the text box is present as the grid but still you can make the text box focus by using

SAPGuiSession(“Session”).SAPGuiWindow(“SAP”).SAPGuiEdit(“your grid name”).SetFocus
SAPGuiSession(“Session”).SAPGuiWindow(“SAP”).SAPGuiEdit(“your grid name”).Set “your value”
SAPGuiSession(“Session”).SAPGuiWindow(“SAP”).SendKey ENTER

for sure this wil work…

thanks!!!
do reply for this whether it is working, if not please paste the error here in the same reply.

40 Mini November 9, 2010 at 5:20 am

Anshoo,

I am facing a problem where the name of the frame of the AUT is changing on runtime.
I have tried using Reg exp ( along with DP ) but it is not helping.
Can u suggest a way which will help me identify the objects on runtime .

Thanks :)

Reply

41 Anshoo Arora November 14, 2010 at 5:32 pm

Mini,

You can skip the Frame from the object hierarchy or use RegEx for it.. For example, replace the below statement:

Browser("").Page("").Frame("").WebElement("").Click

with:

Browser("").Page("").WebElement("").Click
'or
Browser("").WebElement("").Click

or:

Browser("").Page("").Frame("name:=.*partialDescription.*").WebElement("").Click

42 QTP Novice January 5, 2011 at 1:14 pm

Hi Anshoo,

i’m unable to add any objects in a particular window to the object repositry. when i add the complete window,it adds and deletes itself.
please suggest a solution for this strange problem.

Note: This is happening for only few of the windows
Thanks in advance

Reply

43 Anshoo Arora January 10, 2011 at 7:38 am

I don’t think I will be able to help you with this. Your best option may be to contact HP Support.

44 Jena April 7, 2011 at 8:26 pm

Hey Anshoo,

Can you please explain me the following regular expression pattern.
Browser(“title:=Welc\w+\D+\w+”).Page(“title:=Welc\w+\D+\w+”).Image(“file name:=ban\w+\d+\.\w+”).Highlight

Reply

45 Jassi June 25, 2011 at 4:02 am

Hi Anshoo,
Can u pls help me regarding how in a dotnet grid i can verify a particular checkbox is enabled or not??

Reply

46 zakir Hossain December 13, 2011 at 5:15 pm

Hi Anshoo,
Could you please suggest me by descriptive program to solve my problem? I’ll appreciate.
Q. My ordinal identifier keep changing (index or location).Every every time I run the script It’s failed because of ordinal idenfier number. There is any I can do regular expression for ordinal idenfier number>Please help me out. Thank you
zakir

Reply

47 Anshoo Arora December 27, 2011 at 7:04 am

Zakir: Can you point me to the application? Generally if the index is changing, you can use ChildObjects, Visual Relational Identifier, WebTable methods depending on what type of source it has..

48 Mathi December 18, 2011 at 9:06 am

hi admin,
I dont know how to select the Combo box using data table,i want to select and value in drop(HQ,Satellite office,etc.,) i have executed this code can u please go through it and send me a necessary solution ASAP

Dim n,m,i
datatable.Import (“C:\Program Files\HP\Employee detail.xls”)
msgbox 1
For i=1 to n
datatable.SetCurrentRow(i)

Branch=datatable.Value(“Branch”)
Employeefirstname=datatable.Value(“First Name”)

m=datatable.Value(“Branch”, 1)
msgbox m
datatable.SetNextRow
Next

browser(“name:=VCIDEX Management System”).Page(“title:=VCIDEX Management System”).WebList(“html id:=ctl00_Content_cboBranch”).Select Branch

Reply

49 Raj February 7, 2012 at 5:33 pm

web elments are displaying in tree view format. How to get the values of those web elements. Appreciate your help

Reply

50 Bala July 30, 2010 at 12:21 pm

Hi Anshoo

2 things i wish to clarify from you.
1.In the above function Not sure why ” If Not oMatches.Count > 0 Then” is seen thrice in above code
2.Purpose of using Execute
3.In the function RegexSelect(ByVal Object, ByVal sItem)
you have 2 arguments but while calling it is seen as RegisterUserFunc “WebList”, “RegexSelect”, “RegexSelect”

Other one
For this statement Browser(“title:=Welcome: Mercury Tours”).Page(“title:=Welcome: Mercury Tours”).Image(“file name:=banner2.gif”).Click

you have adopted the below regex style characters.I went through Regular-Expressions.Info.
As per the site,\W+ will match ateleast 1 alpanumeric
\d+ will match atleast 1 digit
But in the above statement there is no aplhanumeric character in Welcome and no digit is present,but you have used them..any reason ?

Browser(“title:=\w+\D+\w+ours”).Page(“title:=\w+\D+\w+ours”).Image(“file name:=b\w+2\….”).Highlight

Browser(“title:=\w+\D+\w+ours”).Page(“title:=\w+\D+\w+ours”).Image(“file name:=b\w+2\.gif”).Highlight

Browser(“title:=\w+\D+\w+ours”).Page(“title:=\w+\D+\w+ours”).Image(“file name:=.\w+2\….”).Highlight

I have gone through a couple of articles so far and they is extremely of high class.Great work!!!
QTP Community owes you a lot.

Reply

51 Anonymous August 3, 2010 at 1:17 pm

thanks Anshoo!!!!!!!!

Do I need to write the same “form: \D+” in the Regular expressions of the property value in the Object Repository ?

Reply

52 Anonymous August 3, 2010 at 1:29 pm

Anshoo can you please explain me how it works in the code i am not able to get how it works!!

Reply

53 Anshoo Arora August 5, 2010 at 2:00 pm

Yes. Also, remember the check the CheckBox which says: “regular expression”.

Reply

54 Sivaram S August 10, 2010 at 2:24 am

Anshoo,

The thing is that I cant try these methods as my text box is at the SAPGrid. As far as I know the only option is SetCellData. Do we have any other solution?

Thanks,
Sivaram S

Reply

55 Uday Kumar Sangu August 11, 2010 at 6:34 am

or else you can try converting the value in the datatable to number or string before giving the same as input to the SAP session.

Reply

56 Anonymous August 11, 2010 at 6:35 am

converting into string or number

Reply

57 Sivaram S August 12, 2010 at 4:23 am

Hi Uday,
Thanks for your input.

As you said, I tried SetFocus also. The problem here is that the text box in SAPGuiGrid accepts the data from my datatable and it is visible in the application but the application couldn’t recognize it as the input. There is no errors in coding. In fact, my exact code is…

SAPGuiSession( ).SAPGuiWindow( ).SAPGuiGrid( ).SetCellData 1, “Selection Value”, DataTable(“Broker_Report, dtLocalSheet)

I hard coded test data directly, even variables and data table. I couldn’t automate this. This is something “peculiar”. If you guys know any other alternative methods (except SetCellData) to solve this, I would be much happier.

Thanks,
Sivaram S

Reply

58 Anonymous August 26, 2010 at 4:40 am

Soon after u set the value the next step u do there is?
press Enter button or click some button right …please provide what is to be done…
Thanks Sivaram,

And also can you people tell me “If there are openings on QTP, working experience on QTP is 1yr and overall experience is 2 yrs with 4 months od development experience too.
Thanks you,

Reply

Leave a Comment

{ 3 trackbacks }

Previous post:

Next post: