Search code examples
rubymechanizewww-mechanizemechanize-ruby

Trouble with mechanize and submitting a text area


So I'm trying to submit a simple form that has one text area that looks similar to this

"Lots of stuff that doesn't matter
a couple of lines later
agent => A5656,,5665"

What I'm trying to do is take out the line with the agent. By the way, there are lots of "agent" lines in this file, not that that matters. Anyways here's my code:

new_agent = @elastix.get https://#{@elastix_ip}/index.phpmenu=file_editor&action=edit&file=agent.conf                                                                                                                                      
   new_agent_form = new_agent.forms.first                                                            
   settings = new_agent_form['content']                                                              
   new_agent_form['content'] = settings.gsub(/agent => #{options[:ext]},,#{options[:UserID]}/,'')                                                               
   new_agent_form.encoding = "utf-8"                                                                
   @elastix.submit(new_agent_form,new_agent_form.button_with(:name => "Guardar"))   

There are no errors being thrown and if I "raise new_agent_form.content.inspect" before the submit it shows that the text area does not contain the entry which is what I want. For some reason either that isn't working or I'm missing something. Any help would be appreciated.


Solution

  • The issue has been resolved. It had to do with there being numerous div tags with the name=name. What reason they would do this, I don't know. But you can rest assured that mechanize works as it properly should.