Using Mechanize, is it possible to find a phrase in the HTML of a page, for example, \"email\", and find the next after that, and fill in that input
First find the element with the phrase text:
el = page.at('*[text()*="some phrase"]')
From there you can get the first following input:
input = el.at('./following::input')
Now, find the ancestor form node of that input:
form_node = input.ancestors('form')[0]
Then use that to get the Mechanize::Form object
form = page.form_with(:form_node => form_node)
And now you can fill out the value
form[input[:name]] = 'foo'