# Mechanzie submit fails at gmail login

**URL:** <https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962>\
**Category:** Ruby\
**Created:** [July 21, 2010, 11:11am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962 "2010-07-21T11:11:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 21, 2010, 11:11am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/1 "2010-07-21T11:11:59Z")

</div>

Hallo everybody,

I try to write a script that checks my gmails automatically. But when I  
try to submit the login form, I get the exception 404 =\>  
Net::HTTPNotFound. Can anyone help?

Code is:

@LoginUrl = ‘[http://mail.google.com/mail/](http://mail.google.com/mail/)’  
@agent = Mechanize.new  
@agent.keep\_alive = false  
@agent.user\_agent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.0; de;  
rv:1.9.2) Gecko/20100115 Firefox/3.6’  
@agent.follow\_meta\_refresh = true  
@agent.redirect\_ok = true  
@agent.ca\_file = ‘cacert.pem’

login\_page = @agent.get(@LoginUrl)

begin  
login\_form = login\_page.forms.first  
login\_form.Email = account  
login\_form.Passwd = password

```
login_response_page = @agent.submit login_form

```

rescue Exception =\> e  
print e, “\n”  
end

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 22, 2010, 8:28am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/2 "2010-07-22T08:28:41Z")

</div>

On Wed, Jul 21, 2010 at 6:12 AM, Chugm 456789  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> @agent.keep\_alive = false  
> login\_form.Email = account  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Hi,

try this:

@agent.submit(login\_form,login\_form.button\_with(:name =\> “SignIn”))

I’m not sure about the name of the button but you get the idea

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 22, 2010, 8:33am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/3 "2010-07-22T08:33:07Z")

</div>

thiago damasceno wrote:

> On Wed, Jul 21, 2010 at 6:12 AM, Chugm 456789  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:
> 
> > @agent.keep\_alive = false  
> > login\_form.Email = account  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> Hi,
> 
> try this:
> 
> @agent.submit(login\_form,login\_form.button\_with(:name =\> “SignIn”))
> 
> I’m not sure about the name of the button but you get the idea

Hi,

thanks for your reply. I tried it your way, bt it didn’t help. Still get  
the exception. Seems the agent doesn’t know the form, wehn he tries to  
submit it. But it doesn’t make sence anyway.

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 22, 2010, 8:45am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/4 "2010-07-22T08:45:40Z")

</div>

On Thu, Jul 22, 2010 at 3:33 AM, Chugm 456789  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > 
> 
> ## submit it. But it doesn’t make sence anyway.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Hi,

I’ve looked up and the name of the button is “signIn”. I did a little  
test  
here and everything went fine. Try checking the name.

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 25, 2010, 5:59am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/5 "2010-07-25T05:59:37Z")

</div>

I tested this script on windows xp box with ruby 1.9.1 installation and  
it  
seems just fine here.

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 22, 2010, 1:52pm UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/6 "2010-07-22T13:52:12Z")

</div>

thiago damasceno wrote:

> On Thu, Jul 22, 2010 at 3:33 AM, Chugm 456789  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:
> 
> > > 
> > 
> > ## submit it. But it doesn’t make sence anyway.
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> Hi,
> 
> I’ve looked up and the name of the button is “signIn”. I did a little  
> test  
> here and everything went fine. Try checking the name.

Hey there,

still same problem. I now tried another OS (tested now with Win2k and  
XP). Which OS you take?

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 25, 2010, 6:52am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/7 "2010-07-25T06:52:17Z")

</div>

sorry…there’s something wrong with my mail client to send so many copy  
of  
replies…

---

<div class="post-metadata">

**Author:** ![chugm456789](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chugm456789](https://www.ruby-forum.com/u/chugm456789)\
**Post date:** [July 25, 2010, 6:32am UTC](https://www.ruby-forum.com/t/mechanzie-submit-fails-at-gmail-login/191962/8 "2010-07-25T06:32:23Z")

</div>

I tested this script on windows xp with ruby 1.9.1 installation. It  
seems  
right here
