【问题标题】:calabash issue with UIAlertView in iOS7iOS7中UIAlertView的葫芦问题
【发布时间】:2014-02-09 08:51:37
【问题描述】:

在 iOS 7 之后,我们遇到了使用葫芦进行 UIAlertView 验证的问题。

现在我可以使用

检测警报消息
wait_for_elements_exist(["view:'_UIModalItemRepresentationView'"], :timeout => 20)
query("view:'_UIModalItemRepresentationView' label marked:'#{text}'",).empty?

我的想法来自https://gist.github.com/seanoshea/7613671

但之前(在 iOS 6 中)我们能够像这样清楚地检测到消息和标题

title = query("view:'UIAlertView'",:title).first
msg = query("view:'UIAlertView'",:message).first

有什么方法可以在 iOS7 中做同样的事情吗?我认为“坦率”的人也会这样做https://github.com/moredip/Frank/pull/262

注意:jmoody 请帮助我们处理 Calabash 自动化中的 iOS 7 警报。

【问题讨论】:

  • 我们知道这个问题。这是(我们相信)UIAutomation 中的一个错误。 github.com/calabash/calabash-ios/issues/215我们建议您归档雷达。与此同时,Chathura Palihakkara 发布的代码似乎可以解决。尽管他在 ruby​​ 中的 CamelCase 得到了 -1... ;)
  • 对不起 CamelCase。这是我第一次见到红宝石 :) .

标签: ios ios7 uialertview functional-testing calabash


【解决方案1】:

目前我一直在使用这个解决方案。如果有人遇到同样的问题,可以使用它,直到我们找到一个好的解决方案。

Then /^I should see empty email alert$/ do
  is_alert_exist_with_text("Email cannot be empty.")
  sleep(0.5)
  touch_alert_button("OK")
end
######## 定义函数
def touch_alert_button(button)
  btn = query("view:'_UIModalItemTableViewCell' label marked:'#{button}'").first.empty?
  if (btn)
    screenshot_and_raise "button not found '#{button}'"
  else
    touch("view:'_UIModalItemTableViewCell' label marked:'#{button}'").first
    sleep(0.2)
  end
end

def is_alert_exist_with_text(text)
  unless query("view:'_UIModalItemRepresentationView' label marked:'#{text}'",).empty?
    return true
  else
    screenshot_and_raise "could not find the text '#{text}' in alert view"
  end
end

还有更多...

def is_alert_exist_with_title_and_message(title, message)
  elements = query("view:'_UIModalItemRepresentationView' label", 'text')
  buttons = query("view:'_UIModalItemTableViewCell' label", 'text')
  textLabels = elements - buttons

  if (textLabels.count == 2)
    screenshot_and_raise "Alert Title '#{title}' not found" unless (textLabels[0].eql? title)
    screenshot_and_raise "Alert Message '#{message}' not found" unless (textLabels[1].eql? message)
  else
    screenshot_and_raise "Argument error...isAlertExistWithTitleAndMessage function"
  end
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 2018-03-02
    • 2014-12-09
    • 2016-01-02
    • 1970-01-01
    • 1970-01-01
    • 2014-08-31
    相关资源
    最近更新 更多