Micro Focus QTP (UFT) Forums
VAlue from datasheet is not being picket up - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: VAlue from datasheet is not being picket up (/Thread-VAlue-from-datasheet-is-not-being-picket-up)



VAlue from datasheet is not being picket up - Mala - 02-17-2011

Hi,
I have to enter date in a field based on whether that field is enabled or disabed. My coede reads as follows
Code:
Dim FromDateDisabled
FromDateDisabled = Browser("x").Page("y").WebEdit("FromDate").GetROProperty("Disabled")
If FromDateDisabled = False Then
Browser("x").Page("y").WebEdit("FromDate").Set DataTable("FromDate", dtGlobalSheet)
    Else
    Reporter.ReportEvent micPass,"From Date","From Date Disabled"
In this situation, if the disabled = true, Else statement is not picking up and the test fails.
Any hlep is appreciated please!!


RE: VAlue from datasheet is not being picket up - jsknight1969 - 02-17-2011

Try changing to this

Code:
If lcase(FromDateDisabled) = "false" then

GetROproperty is going to return a string value.

Hope this helps.


RE: VAlue from datasheet is not being picket up - Rekhapramod - 02-17-2011

Hi,

Please try the below code to get the value

Code:
DataTable.Import("C:\Documents and Settings\qtp\Desktop\Login_Details.xls")
WebVal=DataTable.GetSheet(1).GetParameter("Login").Value
Val=Browser("name:=International").Page("title:=International").WebEdit("name:=Uname").GetROProperty("disabled")
If Val=0 Then
     Browser("name:=International").Page("title:=International").WebEdit("name:=Uname").Set WebVal
else
    Reporter.ReportEvent micFail,"Login user name field ","Login username field is read only"
End If

Thanks,
Rekhapramod


RE: VAlue from datasheet is not being picket up - Mala - 02-17-2011

Sorry guys,
Both the solutions didn't work. I guess, it is wrong from my part in explaining the problem. Let me rewrite the problem.
The code after the 'Then' statement is not being picked up whether it is reporter... event or entering the value from the datasheet.
Thanks for all the help I am getting from you guys.


RE: VAlue from datasheet is not being picket up - jsknight1969 - 02-17-2011

I can only see that scenario happening if your script is throwing an error. VbScript stops execution on error unless otherwise specified. You do have to be careful. depending on the errored statment, the next line might be the true statement of the if..condition and not be the results you want.

Code:
on error resume next 'go to next statment
Dim FromDateDisabled
FromDateDisabled = 1 'default to satisfy condition test if error occurs
FromDateDisabled = Browser("x").Page("y").WebEdit("FromDate").GetROProperty("Disabled")
If FromDateDisabled = 0 Then  'disabled is reverse logic too!!!!
  Browser("x").Page("y").WebEdit("FromDate").Set DataTable("FromDate", dtGlobalSheet)
Else
  Reporter.ReportEvent micPass,"From Date","From Date Disabled"
end if

Hope this helps.


RE: VAlue from datasheet is not being picket up - Mala - 02-18-2011

Thank you. Go to next step upon error works. For now, I will give a break and will dig into this. I want to see if there is a way to make this work without the go to next step line.

But, I can't thank you enough for answering my questions.