我需要在模拟器中截取警报框的屏幕截图。我只是得到背景图像而不是弹出/警报框。
我不知道要设置这个 SCREENSHOT_VIA_USB=true 。
有人可以帮我吗?
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