我正在尝试使用机械化填充表单,表单没有name
或id
。
这是我的代码:
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]
但同样的错误。
有什么想法吗?