Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I am new to Calabash and I am looking for a solution... The test case says: I have to verify the text on txt_email Below are the properties of txt_email and I have to verify that the txt_email value is cuong24@yahoo.com.

{
                       "id" => "txt_email",
                  "enabled" => true,
       "contentDescription" => nil,
                    "class" => "android.widget.EditText",
                    "text"  => "cuong24@yahoo.com",
                     "rect" => {
           "center_y" => 342.5,
           "center_x" => 1059.0,
             "height" => 72,
                  "y" => 378,
              "width" => 168,
                  "x" => 975
       },
              "description" => "android.widget.EditText{......}"
   },

I have used a custom step :

When /^I am verify for editText of email$/ do
  performAction('assert_view_property', "txt_email", "text", "cuong24@yahoo.com")
end

but its not working...

Thanks, Cuong Nguyen

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The possible solution is below.

Then /^I verify text in email field$/ do
  expected_text = "cuong24@yahoo.com"
  actual_text = query("EditText id:'txt_email'", :text).first
  unless expected_text == actual_text
    fail "Text in email field is incorrect. Expected '#{expected_text}', but got '#{actual_text}'."
  end
end

It can be parametrized as well, for instance:

Then /^email should be ".*"$/ do |expected_email|
  actual_email = query("EditText id:'txt_email'", :text).first
  unless expected_email == actual_email
    fail "Text in email field is incorrect. Expected '#{expected_text}', but got '#{actual_text}'."
  end
end
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.