有没有办法在执行后发送类似"数据结束"的内容
echo "test" > /dev/tty1
为了获得"输入光标"回到"接收"终端(在这种情况下为tty1)?
如何使用watir保存网站图像,而无需使用open-uri或类似版本重新加载?
我:我不能用的原因
File.open(file_name, 'wb') do |f|
f.write open(img.src).read
end # file open
Run Code Online (Sandbox Code Playgroud)
是图像是在当前(登录)会话中生成的,只有一次,因此无法进行"外部"第二次访问.
II:
browser.images.save()- 仅用于ie - 也没有帮助,它打开了保存对话框.所以它对自动化如此无用.
示例:http://wiki.openqa.org/display/WTR/Save+All+Images+on+a+Webpage
require 'watir'
browser = Watir::Browser.new :ie
browser.goto 'http://google.com'
idx = 0
browser.images.each do |x|
puts idx
idx += 1
location = 'c:\tmp\file-' + idx.to_s + '.jpg'
x.save(location)
end
Run Code Online (Sandbox Code Playgroud)
github来源:http://rubydoc.info/github/watir/watir-classic/Watir/Image
# File 'lib/watir-classic/image.rb', line 48
def save(path)
@container.goto(src)
begin
fill_save_image_dialog(path)
@container.document.execCommand("SaveAs")
ensure
@container.back
end
end
Run Code Online (Sandbox Code Playgroud)
我最好的想法是使用代理获取所有图像.但也许有一种"轮流方式".
环境:
# ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
# …Run Code Online (Sandbox Code Playgroud)