I want to know is there a way to detect UIButton state from calabash/ruby.

Ex. Imagine I have a iphone app which contains a view with a round rect UIButton. This button will hold its state(if you pressed it, it will be on pressed state until you pressed it again). I want to know how to verify the state of that button from calabash test

Given I go to the Home Screen
   Then I should see "name" button is pressed
有帮助吗?

解决方案

Seems Like I found a way to do it. ruby step for the functions is

Then /^I should see "([^\"]*)" is pressed$/ do |text|
    state = query("button marked:'#{text}'", :isSelected)[0]
    state = state.to_i
    if state!=1
      screenshot_and_raise "Current state is not Pressed for button: #{text}"
    end
    sleep(STEP_PAUSE)
end

which goes to steps.rb file

and In calabash feature file you can call it

Then I should see "NameBtn" is pressed

If anybody found improvements please add. Thanks

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top