如何在calabash android中设置SCRENSHOT_VIA_USB = true。

时间:2013-02-23 21:05:11

标签: android calabash

我需要在模拟器中截取警报框的屏幕截图。我只是得到了背景图像,而不是弹出/警告框。

我不知道确切地设置此SCREENSHOT_VIA_USB = true。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:2)

  if ENV["SCREENSHOT_VIA_USB"] == "true"
    device_args = "-s #{@serial}" if @serial
    screenshot_cmd = "java -jar #{File.join(File.dirname(__FILE__), 'lib', 'screenShotTaker.jar')} #{path} #{device_args}"
    log screenshot_cmd
    raise "Could not take screenshot" unless system(screenshot_cmd)
  else
    begin
      res = http("/screenshot")
    rescue EOFError
      raise "Could not take screenshot. App is most likely not running anymore."
    end
    File.open(path, 'wb') do |f|
      f.write res
    end
  end

SCREENSHOT_VIA_USB是环境变量,请尝试:

 export SCREENSHOT_VIA_USB=true