我正在使用 mechanize填写表格,但我想在提交前在网页上查看它。目标是使用预先填写的表单打开浏览器。
require 'mechanize'
mechanize = Mechanize.new
page = mechanize.get('https://www.linuxtoday.com/contribute.html')
form = page.form_with :name => 'upload'
form.sub_name = "mbb"
form.email = "mbb@mbb.com"
form.author_name = "Mr Potatohead"
form.title = "Mr Potatohead writes Ruby"
form.link = "https://potato.potato"
form.body = "More text"
`open #{page.uri}`
调用操作系统打开站点当然是空的形式。我没有看到
page.open
或可用的类似方法。有没有办法实现这一点(使用 Mechanize 或其他 gem )?
最佳答案
这是行不通的,因为设置表单字段甚至不会更新 DOM。
如果您想查看表单数据,您可以检查 form.request_data
关于ruby - 在 ruby 中打开填充表单页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54829789/