
compare
-
- Posts: 25
- Joined: Thu Feb 26, 2009 3:21 pm
compare
Hi! I have a new question!
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?

-
- Posts: 25
- Joined: Thu Feb 26, 2009 3:21 pm
code
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
-
- Posts: 25
- Joined: Thu Feb 26, 2009 3:21 pm
compare
I tried an other code:
But It's wrong too 
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

- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
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.
Regards,
Alex
Ranorex Support Team
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
Alex
Ranorex Support Team
-
- Posts: 25
- Joined: Thu Feb 26, 2009 3:21 pm
compare
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!")