Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem With conversion function
#1
Solved: 6 Years, 1 Month, 2 Weeks ago
Hi, all 

I am  Wajid from USA and new to UFT. I have some problem with my script.

I have written script where I can compare Estimated and actual cost and print Pass or fail result.

My estimated amount is 15700 that changes with every iteration but my actual cost is in currency like $15,700

I have used conversion functions that converts $15,700 to 15700 like Ccur, Cstr, CDbl

When I use above functions on simple test they work properly but when I use them in my script I get Type mismatch error.

I have Created a variable Actual_Price for Actual Price because I am capturing an output from website and the using CAprice variable to convert Actual_Price output.

My script is given below I can share entire script if you want.

Thanks in advance.



Code:
Actual_Price = Browser("Micclass:=Browser","Creationtime:=0","Title:=.*").Page("Micclass:=Page","Creationtime:=0","Title:=.*").webelement("class:=calc-results-total","html id:=ac_max_tmv_result","html tag:=SPAN").GetROProperty("innertext")


Print Actual_Price & "  Before Conversion"

CAprice = Cdbl(Actual_Price)

Print "Actual Price " & Actual_Price  & " Converted Actual Price" & CAprice

Print " and Estimated Price is = " & Estimated_Price

If CAprice = Estimated_Price Then

Print " Actual Price Test Pass"

Else
Print "Actual Price Test Faill"
Reply
#2
Solved: 6 Years, 1 Month, 2 Weeks ago
Please show the exact place where you get the error.

Also, whatever you are comparing, try to convert to the same type.
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply
#3
Solved: 6 Years, 1 Month, 2 Weeks ago
CAprice = Cdbl(Actual_Price)   is the exact place - Here is where I try to convert actual price Variable that contain Price in $15,700 format.

I have a estimated price ( Estimated_Price)  in format like 15700
But on website I have out put (Actual_Price) in format like $15,700

How can I compare above prices to print Test Pass


Quote:If Actual_Price = Estimated_Price Then
Print " Actual Price Test Pass"
Else
Print "Actual Price Test Faill"

Above code does not work


Regards
Reply
#4
Solved: 6 Years, 1 Month, 2 Weeks ago
Problem Solved 

Rewrote the script 

Used

Cdbl(Actual_Price) = Cdbl(Estimated_Price)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,966 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  Pdf to Excel or any other Format Conversion branjitk 1 2,468 06-14-2012, 08:14 AM
Last Post: basanth27
  problem with the function that selects multiple items vijay44 2 2,471 02-06-2010, 10:24 AM
Last Post: vijay44
  problem in wrting function vijay44 1 2,116 02-05-2010, 11:34 AM
Last Post: Saket
  Problem with function call vijay44 2 2,509 01-28-2010, 08:52 PM
Last Post: Anshoo Arora

Forum Jump:


Users browsing this thread: 1 Guest(s)