tags:

views:

47

answers:

1

I am trying to access a form in mechanize with ugly characters in the object name similar to this

agent = Mechanize.new
page  = agent.get('http://domain.com)
form = page.forms[0]
form.ct600$Main$LastNameTextBox = "whatever"
page  = agent.submit(form)

The problem is the $ in the html name is messing with ruby.
Is there another method i could use ie:

form.element_by_name("ct600$Main$LastNameTextBox") = "whatever"

Unfortunately i cant change the html

A: 

I've never touched Ruby, but according to the docs (you did read the docs, right?),

form["ct600$Main$LastNameTextBox"] = "whatever"

should work.

Matti Virkkunen
Schweeeeet, thanks!
ADAM