Closed RutujaNagare closed 5 years ago
change flag to let mutable flag = 0
and make flag
the last line of your function to make it the return line.
Hi,
I tried the solution. but I want to return a flag value outside the for loop. So is tried below code.
let VerifyNotesFromDealDetails(stage : string, approver : string) =
"Verify notes for Approval required " &&& fun _ ->
let mutable flag = 0
let arrStage = stage.Split[|'^'|]
let arrApprover = approver.Split[|'^'|]
let count = arrApprover.Length
let listCount = [1..count]
for i in listCount do
let expectedNotes = "Stage gate at "+arrStage.[i-1]+" until approved by - "+arrApprover.[i-1]
let tempLocator = ".//*[@ng-repeat='appr in vm.deal.ActiveProposal.Approvals']["+(i).ToString()+"]"
let actualNotes = read tempLocator
if expectedNotes.Contains(actualNotes) = true then
flag <- flag + 1
flag
But it is displaying error as 'This expression was expected to have type 'Unit' but here has type 'int'.
Also at the calling point of this function I received NULLValueException
let temp = VerifyNotesFromDealDetails("Proposal^Executed","Rutuja Nagare^Rutuja Nagare")
if temp.ToString().Contains("0") then
TestContext.Progress.WriteLine("Notes on Deal Details are incorrect")
else
TestContext.Progress.WriteLine("Notes on Deal Details are incorrect")
Could you please help..
You've defined a canopy test inside, that is probably the problem
"Verify notes for Approval required " &&& fun _ ->
Can you please suggest how do I collect return value at the calling point of the function? My Function call is let temp = VerifyNotesFromDealDetails("Proposal^Executed","Rutuja Nagare^Rutuja Nagare") if temp.ToString().Contains("0") then TestContext.Progress.WriteLine("Notes on Deal Details are incorrect") else TestContext.Progress.WriteLine("Notes on Deal Details are incorrect")
There I am getting NULLValueException while running the test
I don't understand your question, but it looks like you could get a null reference from temp being null. I dont know what VerifyNotiesFromDealDetails does.
Either way, this is a general F# programming question, not a canopy one. There are plenty of good F# programming books out there, including some free ones.
This is unrelated to canopy.
Hi,
I want to return an integer value from a function having below code.
Could you please help how to write return data type to the function and how to return this flag value from function.
I tried to write return data type after parameters but receiving error "This expression was expected to have type 'int' but here has type 'unit'"