[twill] Fwd: help automating gmail and yahoo mail
Mark Devine
mfmdevine at gmail.com
Wed Jul 8 13:24:45 PDT 2009
sorry I forgot to reply to all there
---------- Forwarded message ----------
From: Mark Devine <mfmdevine at gmail.com>
Date: 2009/7/8
Subject: Re: [twill] help automating gmail and yahoo mail
To: Nat Williams <nat.williams at gmail.com>
Hi Nat
Thanks for the reply. I got the yahoo login working but I still can't
get the gmail code to work. The code is untouched so the 'urlopen
error unknown url type: 'http' error confused me too. As you can see
from the actual code that I didn't have an extra quote in the url. It
is indeed b.submit that is causing the problem. To answer your
question on javascript - both sites have html only options that are
links available to the use upon login. I actually automated the sites
(both javascript versions and html versions) using selenium but I
would rather use twill as I find twill quicker and I have twill
automation in our test framework for all of the GUIs that we have
created. You mentioned the release number and maybe I have an earlier
version (I will check when I get into work tomorrow)
I'll let you know how I get on.
Thanks
Mark
2009/7/8 Nat Williams <nat.williams at gmail.com>:
> Mark,
>
> Your first code snippet works fine for me, on both twill 0.9 and trunk. Is
> it b.submit() that is specifically causing the error?
>
> I'm interested in the last bit of that traceback, though:
>
>> File "/opt/ams/mdevine/lib/python2.
>> 4/urllib2.py", line 1053, in unknown_open
>> raise URLError('unknown url type: %s' % type)
>> urllib2.URLError: <urlopen error unknown url type: 'http>
>
> It looks like a url is getting parsed incorrectly somewhere, or perhaps
> double quoted (as in two sets of quotes). I am unable to reproduce, so I
> can't really tell any more.
>
> As for the yahoo thing, I don't really see what the problem is. Why would
> the inbox show up as a form? Do either of these sites even work without
> javascript?
>
> Nat
>
>
> On Mon, Jun 29, 2009 at 9:00 AM, Mark Devine <mfmdevine at gmail.com> wrote:
>>
>> Hi
>> I need help automating both gmail and yahoo mail using twill. I wonder
>> if someone could point me in the right direction. I used the following
>> code to access gmail but I got a
>> urllib2.URLError: <urlopen error unknown url type: 'http>
>> error when I ran it. I have included the Traceback
>>
>> import twill, string, os
>> b=twill.commands.get_browser()
>> b.set_agent_string("Mozilla/5.0 (Windows; U; Windows NT 5.1;
>> en-GB;rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
>> b.clear_cookies()
>> b.go('http://www.gmail.com')
>> f=b.get_form("1")
>> b.showforms()
>> f['Email']= email
>> f['Passwd'] =password
>> b.clicked(f, f)
>> b.submit()
>>
>> When I run the code I get:
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> File "/home/mdevine/qa/aqa/mfe/site-packages/twill/browser.py", line
>> 115, in go
>> self._journey('open', u)
>> File "/home/mdevine/qa/aqa/mfe/site-packages/twill/browser.py", line
>> 540, in _journey
>> r = func(*args, **kwargs)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 156, in open
>> return self._mech_open(url, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 182, in _mech_open
>> response = UserAgentBase.open(self, request, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 191, in open
>> response = meth(req, response)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py",
>> line 573, in http_response
>> response = self.parent.error(
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 208, in error
>> result = apply(self._call_chain, args)
>> File "/opt/ams/mdevine/lib/python2.4/urllib2.py", line 337, in
>> _call_chain
>> result = func(*args)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py",
>> line 129, in http_error_302
>> return self.parent.open(new)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 156, in open
>> return self._mech_open(url, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 182, in _mech_open
>> response = UserAgentBase.open(self, request, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 191, in open
>> response = meth(req, response)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py",
>> line 573, in http_response
>> response = self.parent.error(
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 208, in error
>> result = apply(self._call_chain, args)
>> File "/opt/ams/mdevine/lib/python2.4/urllib2.py", line 337, in
>> _call_chain
>> result = func(*args)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py",
>> line 129, in http_error_302
>> return self.parent.open(new)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 156, in open
>> return self._mech_open(url, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 182, in _mech_open
>> response = UserAgentBase.open(self, request, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 191, in open
>> response = meth(req, response)
>> File "/home/mdevine/qa/aqa/mfe/site-packages/twill/utils.py", line
>> 455, in http_response
>> "refresh", msg, hdrs)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 208, in error
>> result = apply(self._call_chain, args)
>> File "/opt/ams/mdevine/lib/python2.4/urllib2.py", line 337, in
>> _call_chain
>> result = func(*args)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py",
>> line 129, in http_error_302
>> return self.parent.open(new)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 156, in open
>> return self._mech_open(url, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py",
>> line 182, in _mech_open
>> response = UserAgentBase.open(self, request, data)
>> File
>> "/home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py",
>> line 180, in open
>> response = urlopen(self, req, data)
>> File "/opt/ams/mdevine/lib/python2.4/urllib2.py", line 381, in _open
>> 'unknown_open', req)
>> File "/opt/ams/mdevine/lib/python2.4/urllib2.py", line 337, in
>> _call_chain
>> result = func(*args)
>> File "/opt/ams/mdevine/lib/python2.4/urllib2.py", line 1053, in
>> unknown_open
>> raise URLError('unknown url type: %s' % type)
>> urllib2.URLError: <urlopen error unknown url type: 'http>
>>
>> I also had a problem with yahoo mail when I logged in I found that
>> there was just one form and it had not got the inbox in it:
>>
>> >>> import twill, string, os
>> >>> b=twill.commands.get_browser()
>> >>> b.set_agent_string("Mozilla/5.0 (Windows; U; Windows NT 5.1;
>> >>> en-GB;rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14")
>> >>> b.clear_cookies()
>> >>> b.go("http://mail.yahoo.com")
>> Redirected to <Request for
>> https://login.yahoo.com/config/login_verify2?&.src=ym>
>> ==> at https://login.yahoo.com/config/login_verify2?&.src=ym in
>> 0.37890791893 secs
>> >>> f=b.get_form("1")
>> >>> b.showforms()
>>
>> Form name=login_form (#1)
>> ## ## __Name____________________________ __Type___
>> __ID____________________ __Value__________________
>> 1 .tries hidden (None)
>> 1
>> 2 .src hidden (None)
>> ym
>> 3 .md5 hidden (None)
>> 4 .hash hidden (None)
>> 5 .js hidden (None)
>> 6 .last hidden (None)
>> 7 promo hidden (None)
>> 8 .intl hidden (None)
>> us
>> 9 .bypass hidden (None)
>> 10 .partner hidden (None)
>> 11 .u hidden (None)
>> 81cps6p54h7fv
>> 12 .v hidden (None)
>> 0
>> 13 .challenge hidden (None)
>> 2xPl5mhaAcuDjrKcEK7zP_fLN8.E
>> 14 .yplus hidden (None)
>> 15 .emailCode hidden (None)
>> 16 pkg hidden (None)
>> 17 stepid hidden (None)
>> 18 .ev hidden (None)
>> 19 hasMsgr hidden (None)
>> 0
>> 20 .chkP hidden (None)
>> Y
>> 21 .done hidden (None)
>> http://mail.yahoo.com
>> 22 .pd hidden (None)
>> ym_ver=0&c=&ivt=&sg=
>> 23 login text username
>> 24 passwd password passwd
>> 25 .persistent checkbox persistent
>> [] of ['y']
>> 26 1 .save submit (None)
>> Sign In
>>
>> >>> f['login']= email
>> >>> f['passwd'] =password
>> >>> b.clicked(f, f)
>> >>> b.submit()
>> Note: submit is using submit button: name=".save", value="Sign In"
>> Following HTTP-EQUIV=REFRESH to
>> http://ie.mg41.mail.yahoo.com/dc/launch?.gx=0&.rand=ats9inotdjll8
>> Redirected to <Request for
>> http://ie.mg41.mail.yahoo.com/dc/launch?.gx=0&.rand=ats9inotdjll8>
>> >>> b.showforms()
>>
>> Form #1
>> ## ## __Name____________________________ __Type___
>> __ID____________________ __Value__________________
>> 1 webSrchInput text webSrchInput
>> 2 ei hidden ei
>> UTF-8
>> 3 fr hidden fr_code
>> ush-mailc
>> 4 p hidden p
>> 5 1 searchbutton submit searchbutton
>> Search
>>
>> >>>
>>
>> Any help would be appreciated as I need to create webmail generators for
>> work.
>>
>> Thanks
>>
>> M
>>
>> _______________________________________________
>> twill mailing list
>> twill at lists.idyll.org
>> http://lists.idyll.org/listinfo/twill
>
>
More information about the twill
mailing list