M
M
manitu__pc2017-08-21 11:34:34
ruby
manitu__pc, 2017-08-21 11:34:34

How to work with objects in calabash-cucumber?

Hello community!
In the process of studying calabash-cucumber for testing mobile applications, the question arose of how to work with objects. I took an iOS application for testing, and here on one of the Activities there are 4 questions and 3 answers for each question. To pass to the next Activity, you need to answer these questions, and the answer is the option mark opposite the question. The drawing looks something like this:

|1|0|0| or |1|0|0|
|0|1|0| or |1|0|0|
|0|0|1| or |1|0|0|
|1|0|0| or |0|0|1|

1 - selected option (check-box); 0 - respectively not selected field. There is no binding to the button - no ID, no text. You have to find it by coordinates. And here's the question: how to set an object (button) with given coordinates, and then pass a method to it (for example, object.touch(x, y)) in the step body. Interest arose to check all combinations, and there are 81 of them (there are a lot of steps in steps) - it would be easier with objects (you can write a counter for enumeration). Here are my attempts, but they don't work:
class Tapper
    def tap(x, y)
        perform_action('click_on_screen', x, y)
        #or touch(nil, {:offset => {:x => x.to_i, :y => y.to_i}})
    end
end

Then /^I touch on screen $/ do |x, y|
  @answer_1_1 = Tapper.new
  @answer_1_1.tap(802, 153)
end

Result or:
undefined step

or
undefined method 'perform_action' for Object

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question