Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search

18120 Posts in 4741 Topics- by 31743 Members - Latest Member: suuraj
 

Pages: [1]   Go Down
Print
0 Members and 1 Guest are viewing this topic.
Author Topic: Case sensitivity for values    (Read 304 times)
spsuresh
User
*
Offline Offline

Posts: 37


« on: March 01, 2010, 04:21:49 AM »

Hi all,

Kindly clarify this one for me.

Say i am going to perform a check for a value in a particular field.

Eg:

Say my expected value is "QTP" - in upper case.

In my test at run time this value may appear in upper case or lower case.Hence if it appears as lower case the script fails.
I want the script to pass if the value is correct( The value can be in upper or lower case). Is there any way to achieve this.


Regards
Suresh
Logged
Asiq Ahamed
Moderator
Sr. User
*****
Offline Offline

Posts: 459



WWW
« Reply #1 on: March 01, 2010, 04:45:24 AM »

Hi Suresh,
       You can solve this using regular expression.
Logged
Gautham Maroli
FRProject
Full User
*
Offline Offline

Posts: 155


« Reply #2 on: March 01, 2010, 07:02:20 AM »

You can use LCase or Ucase on the retrived text and compare
Logged
Christian Desserich
Full User
***
Offline Offline

Posts: 121



WWW
« Reply #3 on: March 01, 2010, 07:56:08 AM »

Code
GeSHi (qtp):


Dim runtimeText, regEx

'Change this to match your application -->

runtimeText = Browser("Browser").Page("Page").WebElement("WebElement").GetROProperty("innertext")

'runtimeText = "qtp"



Set regEx = New RegExp

regEx.Pattern = "QTP"

regEx.IgnoreCase = True



'All of these strategies will return True if runtimeText has "QTP",

'"qtp", "Qtp", "qTp", "qtP", "QTp", or "qTP" anywhere in the string



'Asiq's -->

MsgBox regEx.Test(runtimeText)



'Gautham's -->

MsgBox UCase(runtimeText) = "QTP"



'InStr function set to "Textual Compare" -->

MsgBox InStr(1, runtimeText, "QTP", vbTextCompare) > 0



 
Created by GeSHI 1.0.7.20
Logged
chinnu chinnu
Sr. User
****
Offline Offline

Posts: 305


I am working as a SW test engineer and having good knowledge on QTP, i hope it will helpful to me and others.


WWW
« Reply #4 on: March 01, 2010, 10:11:17 AM »

Hi,

1> If ur expected and actual values are same but case sensitive then go
If   StrComp(act,exp,1)=0 Then
   Msgbox"correct
   else
   Msgbox"not correct
End If

2> If ur expected is a part of actual value but case sensitive then go
   (means exp string within actual string)
If   InStrComp(1,act,exp,1)>0 Then
   Msgbox"correct
   else
   Msgbox"not correct
End If

3> mexp=LCase(Exp)'Convert to Lcase
   mAct=LCase(Actual)'Convert to Lcase

If mexp=mAct Then
   Msgbox"correct
   else
   Msgbox"not correct
End If
Logged

Always with you,
Chinnu
Thamarai Kannan Selvan
User
*
Offline Offline

Posts: 15


« Reply #5 on: March 03, 2010, 05:17:23 AM »

Please try this method.


Read the value from application during run time. Use "Ucase" function, to convert the text to upper case, you issue will be resolved.
Logged
Pages: [1]   Go Up
Print
Jump to: