我有以下代码
require 'watir-wedriver'
browsers = ['chrome', 'safari']
browsers.each do |browserName|
browser = Watir::Browser.new :browserName
# more code here
end
browserName
在这里不起作用,因为该命令按字面意思解释它(即,它正在读取browser = Watir::Browser.new :browserName
而不是browser = Watir::Browser.new :chrome
后跟browser = Watir::Browser.new :safari
.
如何使该变量在那里扩展?