Santhi Bharath
Santhi Bharath

Reputation: 2878

Calabash Android How to Get data from TextViews and compare the same

I have three Textviews, I want to compare difference of the data of two Textviews with third one. I am using below code, but it doesn't work for me. Please help me to solve this.

Then /^I checked "([^\"]*)" transactions count  with first TextView "([^\"]*)" second TextView "([^\"]*)"$/ do |nid,rid,vid|


 totalReceivedCount=query("TextView id:'#{rid}'", :text).first.to_i
 totalReturnedCount=query("TextView iid:'#{vid}'", :text).first.to_i
 totalSummaryCount=query("TextView id:'#{nid}'", :text).first.to_i

 unless totalSummaryTransactionCount == totalReceivedCount - totalReturnedCount
 fail "Total not equal"
 end
end

Upvotes: 1

Views: 513

Answers (1)

Vishal Adatia
Vishal Adatia

Reputation: 94

Then /^I compared "([^\"]*)" Text "([^\"]*)" void "([^\"]*)"$/ do |id1,id2,id3|

n1 = query("TextView id:'#{id1}'", :text).first.to_i
n2 = query("TextView id:'#{id2}'", :text).first.to_i
n3 = query("TextView id:'#{id3}'", :text).first.to_i
n4=n2-n3

if n1 == n4
puts "Success Logic" 
else
puts " Logic" 
end 
end

Upvotes: 2

Related Questions