Question about mechanize and input type image

Hello i’m having a issue trying to submit a form using mechanize. The
thing
is that the form don’t have a submit button but a input type=“image”.

Someone knows how to do this with mechanize or if its not possible
with mechanize there is another library to do this?

This is the form im trying to send

User name Password
Remember me
Forgot password?

On 9 August 2011 17:13, art tav [email protected] wrote:

I think the problem may be that you are trying to nest a form within a
table. The only way you can put a form inside a table is if the form
lies entirely within one cell of the table. A table may reside
entirely within a form of course.

Colin

I’m not sure if that’s the problem because i can work with the form
assing values to the fields of uname and upass. I’ve tried to find a
solution for this issue in google but couldn’t find a solution that
works.

May be a little more information will help i’m using mechanize 2.0.1 and
this is some of the code that i use for sending the form.

page = agent.get(url_mail)

log = page.forms.first
log.uname = “user”
log.upass = “password”

logeado = agent.submit(log)#i used this after other unsuccessful atempts
to
#submit the form. I’m not sure if the agent.submit is clicking the right
#button but it returns a response but…
sl = logeado.field(“country”) #i got the error undefined method ‘field’
for Mechanize::page:0xxxxxxxx

On 9 August 2011 17:59, art tav [email protected] wrote:

I’m not sure if that’s the problem because i can work with the form
assing values to the fields of uname and upass. I’ve tried to find a
solution for this issue in google but couldn’t find a solution that
works.

The first thing to do is to get to valid html. You cannot make any
conclusions about anything with invalid html. To check that it is
valid view the page source (View > Page Source or similar in your
browser) copy the complete text and paste it into the w3c html
validator. When you have invalid html the browser (which will know
that it is invalid) has to guess what you meant and it may not guess
the way you intended.

There is no point doing anything else until you have valid html. A
golden rule of problem solving, if you know that something is not
right then fix it before worrying about other things that may or may
not be part of the problem.

Colin

Colin L. wrote in post #1015781:

The first thing to do is to get to valid html. You cannot make any
conclusions about anything with invalid html. To check that it is
valid view the page source (View > Page Source or similar in your
browser) copy the complete text and paste it into the w3c html
validator. When you have invalid html the browser (which will know
that it is invalid) has to guess what you meant and it may not guess
the way you intended.

There is no point doing anything else until you have valid html. A
golden rule of problem solving, if you know that something is not
right then fix it before worrying about other things that may or may
not be part of the problem.

Colin

Thanks for this information, i didn’t know that w3s have a validator for
html, now i can use it to check things faster that using firebug or
other things.

It seems like the site have a lot of things wrong, like i spected for
what i saw the first time in the source code, but the thing here is that
i don’t own that site so i can’t do something about that issues.

On 9 August 2011 21:08, art tav [email protected] wrote:

There is no point doing anything else until you have valid html. A
It seems like the site have a lot of things wrong, like i spected for
what i saw the first time in the source code, but the thing here is that
i don’t own that site so i can’t do something about that issues.

I don’t understand, you are trying to get a form working on a site
that you do not have control over?

Colin

The
thing
is that the form don’t have a submit button but a input type=“image”.

Have you tried writing your code as if it has a submit button?

On 10 August 2011 18:14, art tav [email protected] wrote:

That’s correct, so i can’t change the form or the input image for a
button.

OK, sorry, I had forgotten what your original question was. I was
thinking that you were describing a problem specific to the form that
you provided the detailed html for. Your best bet might be the
mechanize mailing list (see http://mechanize.rubyforge.org/). Of
course it may be that what you want to do is not possible as mechanize
might not be capable of interpreting the invalid html.

Colin

That’s correct, so i can’t change the form or the input image for a
button.