2

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

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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