无法使用机械化填充表格

时间:2017-03-29 00:18:15

标签: ruby mechanize

我正在尝试使用机械化填充表单,表单没有nameid

这是我的代码:

require 'mechanize'

a = Mechanize.new
page = a.get("http://www.lauradesmaison.book.fr/contact/")
form = page.form()
form['nom'] = "Name"
form['societe'] = "Society"
form['email'] = "user@mail.com"
form['tel'] = "0123456789"
form['texte'] = "My message"
button = form.button_with(:name => "submit-contact")
page = a.submit(form, button)

puts "Message has been sent."

但我有一个undefined method [] =' for nil:NilClass错误行6。

我尝试使用form = page.forms[0]但同样的错误。 有什么想法吗?

0 个答案:

没有答案