0

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.

Kibet Yegon
  • 2,763
  • 2
  • 25
  • 32
David Hahn
  • 740
  • 9
  • 26
  • Your variable names need help, you seem to be confusing page with agent. I would bet that regex has unescaped special chars but I can't tell from what you posted. Also why change the form's encoding? – pguardiario Aug 24 '12 at 23:45
  • I've never been one to excel at variable names. But it can't be the regex, like I said if I inspect the contents of the text area after the regex it appears with the line absent. As for the encoding, I had to manually set it due to some inconsistency. – David Hahn Aug 24 '12 at 23:58

1 Answers1

0

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.

David Hahn
  • 740
  • 9
  • 26