Certain lookup values are not selected

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Saha
Posts: 39
Joined: Tue Mar 01, 2011 6:20 pm

Certain lookup values are not selected

Post by Saha » Fri Apr 15, 2011 4:48 pm

Hi,

I have a function which checks for all lookup values in combo box fields in the application.
It works for most of the lookups for fails for few items .
For example- Below mentioned are the lookups which is not selected while excuting. Cursor moves to the left most corner of the window and the lookup value is not selected in the combo box. It does not through any exception but continues with the next value in the list.

Any idea what is missing here.
Lookups
-----------
3 Payments (Equal) - 33.3% per payment
4 Payments (Equal) - 25% per payment
3 Payments (50% 1st Payment, 25% for the next 2 Payments)
3 Payments (40% 1st Payment, 30% for the next 2 Payments)

Thanks,
Saha

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Certain lookup values are not selected

Post by Ciege » Fri Apr 15, 2011 5:02 pm

Which ones (or a sample of) does it select properly?
What's different between the ones that work and the ones that don't?
Can you share you code that does the work?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Saha
Posts: 39
Joined: Tue Mar 01, 2011 6:20 pm

Re: Certain lookup values are not selected

Post by Saha » Fri Apr 15, 2011 5:43 pm

Fails for all these
3 Payments (Equal) - 33.3% per payment
4 Payments (Equal) - 25% per payment
3 Payments (50% 1st Payment, 25% for the next 2 Payments)
3 Payments (40% 1st Payment, 30% for the next 2 Payments)

Works fine for all other list items in the same combo box. some example of values which works fine.
Public vehicle infraction
At the Same Time Each Day
Job by Job Basis

Code -
Public Sub CheckLookupInUI(lookupItem As String, fieldName As String)
	Dim elementName As String = Nothing
	Dim isElementFound As Boolean = False
	Dim isLookupFound As Boolean = False
	Dim item As ListItem = Nothing
	Dim element As WebElement = Nothing
	'MsgBox("fieldName:"&fieldName)
	elementName = GetElementName(fieldName)
	'MsgBox("Element Name :" &elementName)
	Report.Info("lookup-"&lookupItem)
	isElementFound = webDoc.TryFindSingle(".//select[@id~'.*" & elementName & "$']", Adapter.DefaultSearchTimeout, element)
	If (isElementFound and element.EnsureVisible) Then
		element.focus()
		element.Click(Location.Center, 100)
		'msgBox(lookupItem)
		isLookupFound = Host.Local.TryFindSingle(".//listitem[@accessiblename='" &lookupItem & "']", Adapter.DefaultSearchTimeout, item)
		If (isLookupFound) Then			
			item.Click(Location.Center, 100)
		Else Report.Failure("Combo value not found-" &lookupItem)
		End If
	Else Report.Failure("Element not found :" &fieldName)
	End If
	
End Sub

Saha
Posts: 39
Joined: Tue Mar 01, 2011 6:20 pm

Re: Certain lookup values are not selected

Post by Saha » Fri Apr 15, 2011 5:45 pm

Forgot to answer your seond question
Only difference i see in the list values which does not work in it has '%' , '-' in it.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Certain lookup values are not selected

Post by Ciege » Fri Apr 15, 2011 5:53 pm

I agree... It sure looks like it is failing due to the special characters in the LookupItem.

Try spying on the values in question and see how RanorexSpy resolves the special characters. Since you are using a regular expression in your XPath you may need to put in some extra formatting code if your LookupItem contains special characters then you may need to add in some escape characters.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Saha
Posts: 39
Joined: Tue Mar 01, 2011 6:20 pm

Re: Certain lookup values are not selected

Post by Saha » Mon Apr 18, 2011 6:04 pm

I have tried with spy and I am able to see the lookup values properly without any special formatting.
I have attached the snapshot for this lookup field.

Thanks,
Saha
You do not have the required permissions to view the files attached to this post.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Certain lookup values are not selected

Post by Ciege » Mon Apr 18, 2011 6:07 pm

Well, I may have misspoke... Since Spy is not representing the elements using a regular expression, it probably won't show escaped characters. But, since you are using a regular expression in your code you will need to escape the special characters properly according to RegEx standards.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Certain lookup values are not selected

Post by Support Team » Tue Apr 19, 2011 8:09 am

Hi,

I have tried your code and it is working like a charm. I had to replace your GetElementName method, but I think this method shouldn't be the problem. But could you please post this piece of code too?

I think it's not the RegEx. You don't use this for the list items, only for the ComboBox the RegEx is used and this shouldn't be a problem, because there are no special characters inside the ID attribute.
Saha wrote:cursor moves to the left most corner of the window and the lookup value is not selected in the combo box.
Do you get any warning in your report if Ranorex clicks to "0;0"?
Have you tried to put a short delay after you click the combobox?

Regards,
Peter
Ranorex Team

Saha
Posts: 39
Joined: Tue Mar 01, 2011 6:20 pm

Re: Certain lookup values are not selected

Post by Saha » Wed Apr 20, 2011 6:35 pm

Hi Peter,

No I have not got any warning in report.
No I have not added any delay, as my lookup search work for most of the lookups.

Did this work for you with the specific lookup values which I have mentioned in the previous thread?
For example -
3 Payments (Equal) - 33.3% per payment
4 Payments (Equal) - 25% per payment
3 Payments (50% 1st Payment, 25% for the next 2 Payments)
3 Payments (40% 1st Payment, 30% for the next 2 Payments)


GetElementName method just look for the element in an access db and give the element ID back.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Certain lookup values are not selected

Post by Support Team » Thu Apr 21, 2011 9:56 am

Hi,

Please take a look to the attached project. I've used your code and also the HTML page I have used is inside the zip file.

Regards,
Peter
Ranorex Team
vb_RanorexTest.zip
You do not have the required permissions to view the files attached to this post.