我正在尝试执行以下操作,但无法找到输入邮政编码的表单名称。
require 'mechanize'
agent = Mechanize.new
page = agent.get('https://www.wendys.com/en-us/Location')
wendy_form = page.form('find_loc') #name of the form
wendy_form.altZip = '10013'
#altZip is the input form name
page = agent.submit(wendy_form)
page.search('p.store_address').each do |li|
puts li.content
end
这是我想要的形式。
<form data-bind="submit: destinationFinder.huntViaAddressForm, visible: destinationFinder.isShowingResultsView() || ! routePlanner.destination.exists()" id="find_loc" style="">
收到以下错误:
2.rb:9:in `<main>': undefined method `altZip=' for nil:NilClass (NoMethodError)
答案 0 :(得分:0)
答案 1 :(得分:0)
你必须解决两个问题:
找到合适的表格。为此,您应该使用id:
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
if #available(iOS 9.0, *) {
UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).defaultTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
} else {
// Fallback on earlier versions
}
使用正确的方法设置altZip字段:
form = page.form_with(:id => "find_loc")