compare

Ranorex Spy, Recorder, and Studio.
paracelsus
Posts: 25
Joined: Thu Feb 26, 2009 3:21 pm

compare

Post by paracelsus » Tue Mar 10, 2009 2:17 pm

Hi! I have a new question! :D I made a test, and I'd like to compare to string. One of them is in an external xml file and the other generated at the end of the test. I tried to make a VB.NET code with if condition but it was wrong. Somebody know to help me?

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

Post by Ciege » Tue Mar 10, 2009 3:57 pm

Can you maybe post a bit if your code so we can see what you did and make suggestions on how to fix it?

paracelsus
Posts: 25
Joined: Thu Feb 26, 2009 3:21 pm

code

Post by paracelsus » Tue Mar 10, 2009 4:19 pm

This is my code

Code: Select all

Dim ar As String =m_node.ChildNodes.Item(5).InnerText
...
...
Dim ar2 As String
			ar2=spanTagCtl00_MPBISSContent_lblO.InnerText
			
If ar2 like ar
        report.Info("VIZSGALAT","AZ ÉRTÉKEK MEGEGYEZŐEK")
Else
	report.Error("VIZSGALAT","AZ ÉRTÉKEK KÜLÖNBÖZŐEK")
End If

paracelsus
Posts: 25
Joined: Thu Feb 26, 2009 3:21 pm

compare

Post by paracelsus » Wed Mar 11, 2009 11:27 am

I tried an other code:

Code: Select all

If String.Compare(ertek,ar)=-1 or String.Compare(ertek,ar)=1
report.Error("VIZSGALAT","A két érték nem egyező")
Else If String.Compare(ertek, ar)=0
report.Info("VIZSGALAT","A két érték megegyező")
End If
But It's wrong too :(

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Wed Mar 11, 2009 1:50 pm

Could you please post the values of the "ertek" and "ar" variables? I would recommend rewriting this code, because the String.Compare method may return other values than -1, 0, and 1.

Code: Select all

If String.Compare(ertek, ar)=0
report.Info("VIZSGALAT","A két érték megegyező")
Else
report.Error("VIZSGALAT","A két érték nem egyező")
End If
Regards,
Alex
Ranorex Support Team

paracelsus
Posts: 25
Joined: Thu Feb 26, 2009 3:21 pm

compare

Post by paracelsus » Wed Mar 11, 2009 2:19 pm

I have made it, yet. I split the string witch is in the variables and after this I compare the two variables. Thx for your help. I write for you my code:

Code: Select all


Dim words As String() = ertek.Split(New Char() {" "c})
Dim word As String = words(0) + words(1)
			
report.Info("Vizsgalat", word & "")
report.Info("Vizsgalat",ar & "")
If String.Compare(ar,word)=0
report.Info("VIZSGÁLAT","A két érték megegyező")
Else 
report.Error("HIBA","A két érték nem megegyező")
End If
	
report.Success("TESZT","A teszt végrahajtása befejeződött!")