Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Mechanize复选框,提交并随后显示字段_Ruby_Mechanize - Fatal编程技术网

Ruby Mechanize复选框,提交并随后显示字段

Ruby Mechanize复选框,提交并随后显示字段,ruby,mechanize,Ruby,Mechanize,这是我的Ruby Mechanize代码,在接近结尾的地方,我被复选框卡住了,在页面上选择第二次提交,并在单击第二次提交按钮后显示一些字段。我已经使用了和搜索周围,并找到了几种方法来做一个复选框。其中一个可能正在工作,但我无法在表单和视图字段中选择要查看的第二个提交 require 'rubygems' require 'mechanize' agent = Mechanize.new page = agent.get(URL) #Grab form surescripts_form = p

这是我的Ruby Mechanize代码,在接近结尾的地方,我被复选框卡住了,在页面上选择第二次提交,并在单击第二次提交按钮后显示一些字段。我已经使用了和搜索周围,并找到了几种方法来做一个复选框。其中一个可能正在工作,但我无法在表单和视图字段中选择要查看的第二个提交

require 'rubygems'
require 'mechanize'

agent = Mechanize.new
page = agent.get(URL)

#Grab form
surescripts_form = page.form_with(:action => 'Login.aspx?timeout=true')

#Fill in login and password
surescripts_form.LoginIDTextBox = Username
surescripts_form.PasswordTextBox = Password

#Select the user profile form
surescripts_user_form = page.form_with(:name => 'form1')

FirstName = FirstNameVariable
LastName = LastNameVariable
DEA = DEANumberVariable
NPI = NPINumberVariable

surescripts_user_form['ctl00$CPHMainContent$TxtFirstName'] = FirstName
surescripts_user_form['ctl00$CPHMainContent$TxtLastName'] = LastName
surescripts_user_form['ctl00$CPHMainContent$TxtDEA'] = DEA
surescripts_user_form['ctl00$CPHMainContent$NPI'] = NPI
surescripts_user_form['ctl00$CPHMainContent$TxtAddressLine1'] = AddressLine1
#surescripts_user_form['ctl00$CPHMainContent$TxtAddressLine2'] = AddressLine2
surescripts_user_form['ctl00$CPHMainContent$TxtCity'] = City
surescripts_user_form['ctl00$CPHMainContent$DdlState$StateList'] = "New York"
surescripts_user_form['ctl00$CPHMainContent$TxtZip'] = Zip
surescripts_user_form['ctl00$CPHMainContent$TxtPrimaryPhone'] = PrimaryPhone
surescripts_user_form['ctl00$CPHMainContent$TxtFax'] = Fax
#surescripts_user_form['CPHMainContent_CblServiceLevel_1'] = 1
#surescripts_user_form['CPHMainContent_CblServiceLevel_2'] = 1

#Need help with this Check Box
#surescripts_user_form['CPHMainContent_CblServiceLevel_6'] = 1
#surescripts_user_form.checkbox_with(:value => '32').check
#surescripts_user_form.checkbox_with(:name => /CPHMainContent_CblServiceLevel_6/).check

#Need help with this Submit
#page = agent.submit(surescripts_user_form['ctl00$CPHMainContent$BtnSave'])
#page = surescripts_user_form.submit(page.form_with(:action => /.*/).submits[22])
page = agent.submit(surescripts_user_form, surescripts_user_form.buttons.last)

#Need help with displaying fields on the next page
pp page.body
pp surescripts_user_form

#Displays all my input values
File.open('form_log.txt', 'w') do |f|  
  # use "\n" for two lines of text  
  f.write surescripts_user_form.fields.each { |d| puts d.name }
end  

#Displays html of the page
File.open('page_log.txt', 'w') do |f|  
  # use "\n" for two lines of text  
  f.write page.labels_hash()
end  

我可能也有同样的问题,最近更新了mechanize Gei得到Eric的帮助:)这是我的误解我可能也有同样的问题,最近更新了mechanize Gei得到Eric的帮助:)这是我的误解