Question about automation Gmail with Watir

121 views
Skip to first unread message

Alek

unread,
Feb 23, 2010, 4:17:30 AM2/23/10
to Watir General
Hi

I just started 'playing' with Watir so I am really newbie.
I started from automating Gmail (http://wiki.openqa.org/display/WTR/
Automating+Gmail+with+Watir?&#comments). It looks that this script is
based on old Gmail html layout.

Canvas_frame.button(:text, 'Send').click # Send the message .

Above command is not relevant anymore : now in Gmail 'Send' feature is
not <button> but <div> tag


Below xpath for 'Send' inside Canvas_frame:

/html/body/div[1]/div[2]/div/div[2]/div[1]/div[3]/div[1]/div/div/
div[2]/div/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div[@id=':
9c']/div/div/div[@id=':88']/div[@id=':85']/div/div/div/div[2]/b

and complete HTML inside Canvas_frame :

<HTML class="cQ" closure_hashCode_8441od="543"><BODY class="cP"
closure_hashCode_8441od="34"><DIV style="POSITION: relative"
closure_hashCode_8441od="544"><DIV class="nH" style="WIDTH: 1660px"
closure_hashCode_8441od="545"><DIV class="nH" style="POSITION:
relative" closure_hashCode_8441od="158"><DIV class="nH"
closure_hashCode_8441od="546"><DIV class="no"
closure_hashCode_8441od="547"><DIV class="nH nn" style="WIDTH: 1431px"
closure_hashCode_8441od="548"><DIV class="nH"
closure_hashCode_8441od="549"><DIV class="nH q0CeU x"
closure_hashCode_8441od="550"><DIV class="nH"
closure_hashCode_8441od="551"><DIV class="l m"
closure_hashCode_8441od="552"><DIV class="l n" style="MARGIN-LEFT:
4px" closure_hashCode_8441od="553"><DIV class="k" style="PADDING-
RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px 4px
0px 0px; PADDING-TOP: 0px" closure_hashCode_8441od="554"><DIV
class="diLZtc" closure_hashCode_8441od="555"><DIV class="nH"
closure_hashCode_8441od="556"><DIV class="nH"
closure_hashCode_8441od="557"><DIV class="nH"
closure_hashCode_8441od="558"><DIV class="nH"
closure_hashCode_8441od="1526"><DIV class="nH"
closure_hashCode_8441od="1527"><DIV class="nH"
closure_hashCode_8441od="1528"><DIV
closure_hashCode_8441od="1434"><DIV class=""
closure_hashCode_8441od="1529"><DIV id=":5f"
closure_hashCode_8441od="1571"><DIV class="eh"
closure_hashCode_8441od="1572"><DIV class="dW"
closure_hashCode_8441od="1573" role="navigation"><DIV class="dX J-Jw"
id=":3p" hideFocus closure_hashCode_8441od="1443"
unselectable="on"><DIV class="J-K-I J-J5-Ji Bq L3" id=":3s"
closure_hashCode_8441od="1436" act="" unselectable="on"><DIV class="J-
J5-Ji J-K-I-Kv-H" unselectable="on"><DIV class="J-J5-Ji J-K-I-J6-H"
unselectable="on"><DIV class="J-K-I-KC" unselectable="on"><DIV
class="J-K-I-Jz" unselectable="on"><B unselectable="on"> Send </B></
DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></
DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></
DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></BODY></HTML>


I have tried following without success:

1. Click <b> tag using "element_by_xpath"

canvas_frame.element_by_xpath("/html/body/div[1]/div[2]/div/div[2]/
div[1]/div[3]/div[1]/div/div/div[2]/div/div/div/div/div[2]/div/div[2]/
div/div/div/div[1]/div[@id=':9c']/div/div/div[@id=':88']/div[@id=':
85']/div/div/div/div[2]/b").click

- element_by_xpath is not supported inside frame (NoMethodError:
undefined method `element_by_xpath' for #<Watir::Frame:0x33c2ec4>)

2. I have added Watir::B class to non_control_elements.rb and then
tried :

canvas_frame.B(:text,"Send").click

Watir works fine, however no action on page - mail is not sent

3. I was trying to click parent div(s) as follows

canvas_frame.div(:class,"J-K-I-Jz").click
canvas_frame.div(:class,"J-K-I-KC").click
canvas_frame.div(:class,"J-J5-Ji J-K-I-J6-H").click
canvas_frame.div(:class,"J-K-I J-J5-Ji Bq L3").click

Watir works fine, however no action on page - mail is not sent

Does anyone has an idea how to get to this <div> or <b> and click
'Send' using watir ?

Željko Filipin

unread,
Feb 23, 2010, 5:21:09 AM2/23/10
to watir-...@googlegroups.com
On Tue, Feb 23, 2010 at 10:17 AM, Alek <aleksand...@gmail.com> wrote:
> I just started 'playing' with Watir so I am really newbie.
> I started from automating Gmail

Please do not use Gmail to learn how to use Watir. Gmail is full of strange things. If you really want to use Gmail, then switch to basic html view until you are familiar with Watir.

I would suggest that you read this:

http://wiki.openqa.org/display/WTR/Quick+Start
http://wiki.openqa.org/display/WTR/Tutorial

Željko
--
watir.com - community manager
pledgie.com/campaigns/2982 - donate to Watir
watirpodcast.com - host
testingpodcast.com - podcasts on software testing. all of them

Alek

unread,
Feb 23, 2010, 5:30:06 AM2/23/10
to Watir General
Thanks Željko

I have went through this pages already.

I understand your concept, and probably I will need to try some easier
web or switch to basic, however back to my question is this possible
to click this div using watir ?

I would not start from gmail, however this script looked very
appealing and it is not working on "fatview" gmail


thanks
Alek

On 23 Lut, 11:21, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:


> On Tue, Feb 23, 2010 at 10:17 AM, Alek <aleksander.lip...@gmail.com> wrote:
> > I just started 'playing' with Watir so I am really newbie.
> > I started from automating Gmail
>
> Please do not use Gmail to learn how to use Watir. Gmail is full of strange
> things. If you really want to use Gmail, then switch to basic html view
> until you are familiar with Watir.
>
> I would suggest that you read this:
>

> http://wiki.openqa.org/display/WTR/Quick+Starthttp://wiki.openqa.org/display/WTR/Tutorial

Bill Agee

unread,
Feb 23, 2010, 3:12:24 PM2/23/10
to watir-...@googlegroups.com
It's probably possible to fix the gmail script used in the wiki example, but it would take some effort, and it would no longer be suitable as a "simple" Watir example. :)

So, with that in mind, I suggest we remove the gmail wiki page.  I commented out the contents of the article, but did not see a way to remove the "Automating Gmail with Watir" page from the list of child pages of "Simple Examples".

Could someone with full privileges on the wiki take a look and see if they can remove the gmail page from the Simple Examples child list?

Just for the record, here is some detail on the current state of why clicking the "Send" button in gmail is broken:

Watir is able to locate the divs containing the "Send" text, but the way gmail is built, if Element#click is used on any of the nested divs that make up the button, the click is somehow blocked.

I also noticed that I could not use the Element#focus method on most of the nested divs that contain gmail buttons.  Probably the same root cause as the click problem.

In IE, this may have something to do with the use of the "unselectable='on'" attribute value that is present on most of the button divs.

In Firefox I noticed that some of the same divs have this: "style='-moz-user-select: none;'".  However, I didn't do any investigation with FF.

Using both Element#ole_object= and the IE dev toolbar, I tried setting "unselectable='off'" for each nested div that makes up the "Send" button, but this didn't lead anywhere promising, unless I missed something.

Thanks
Bill


--
You received this message because you are subscribed to the Google Groups "Watir General" group.
To post to this group, send email to watir-...@googlegroups.com
Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to watir-genera...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/watir-general

Charley Baker

unread,
Feb 23, 2010, 5:49:59 PM2/23/10
to watir-...@googlegroups.com
Agreed, I would say dump it and somewhere in the intial guides, since this is a common question, put an NB: saying don't start with gmail.

-c

Alek

unread,
Feb 24, 2010, 3:06:06 AM2/24/10
to Watir General
So we can say we have to issue here :

1. Aware newbies to not start watir automation with Gmail , since it's
html is too complicated ;) and put this is on wiki.

2. Is this possible to click using waitr nested "unselectable" div on
Gmail ? (<DIV


class="J-K-I-Jz" unselectable="on"><B unselectable="on"> Send </B></

DIV>)

thanks for all replies,
Alek

> > On Tue, Feb 23, 2010 at 2:30 AM, Alek <aleksander.lip...@gmail.com> wrote:
>
> >> Thanks Željko
>
> >> I have went through this pages already.
>
> >> I understand your concept, and probably I will need to try some easier
> >> web or switch to basic, however back to my question is this possible
> >> to click this div using watir  ?
>
> >> I would not start from gmail, however this script looked very
> >> appealing and it is not working on  "fatview" gmail
>
> >> thanks
> >> Alek
>
> >> On 23 Lut, 11:21, Željko Filipin <zeljko.fili...@wa-research.ch>
> >> wrote:
> >> > On Tue, Feb 23, 2010 at 10:17 AM, Alek <aleksander.lip...@gmail.com>
> >> wrote:
> >> > > I just started 'playing' with Watir so I am really newbie.
> >> > > I started from automating Gmail
>
> >> > Please do not use Gmail to learn how to use Watir. Gmail is full of
> >> strange
> >> > things. If you really want to use Gmail, then switch to basic html view
> >> > until you are familiar with Watir.
>
> >> > I would suggest that you read this:
>

> >>http://wiki.openqa.org/display/WTR/Quick+Starthttp://wiki.openqa.org/...


>
> >> > Željko
> >> > --
> >> > watir.com - community manager
> >> > pledgie.com/campaigns/2982 - donate to Watir
> >> > watirpodcast.com - host
> >> > testingpodcast.com - podcasts on software testing. all of them
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Watir General" group.
> >> To post to this group, send email to watir-...@googlegroups.com
> >> Before posting, please read the following guidelines:
> >>http://wiki.openqa.org/display/WTR/Support
> >> To unsubscribe from this group, send email to

> >> watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog legroups.com>


> >> For more options, visit this group at
> >>http://groups.google.com/group/watir-general
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Watir General" group.
> > To post to this group, send email to watir-...@googlegroups.com
> > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > To unsubscribe from this group, send email to

> > watir-genera...@googlegroups.com<watir-general%2Bunsubscribe@goog legroups.com>

Željko Filipin

unread,
Feb 24, 2010, 4:56:43 AM2/24/10
to watir-...@googlegroups.com
On Tue, Feb 23, 2010 at 9:12 PM, Bill Agee <bill...@gmail.com> wrote:
> I suggest we remove the gmail wiki page.

Done.

Željko

Alister Scott

unread,
Feb 25, 2010, 5:42:48 PM2/25/10
to Watir General
It makes sense to get rid of the Gmail example, because why you would
ever want to automated a GUI to send an email is the question.
It is *so* easy to send an email through ruby itself.

On Feb 24, 7:56 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:

Felipe Knorr Kuhn

unread,
Feb 25, 2010, 6:01:20 PM2/25/10
to watir-...@googlegroups.com
Google engineers might be using Watir to test their upcoming Gmail Labs apps!

j/k :)

FK

Alister Scott

unread,
Feb 25, 2010, 11:01:09 PM2/25/10
to Watir General
Or spammers might be using Watir to spam the world :(

On Feb 26, 9:01 am, Felipe Knorr Kuhn <fkn...@gmail.com> wrote:
> Google engineers might be using Watir to test their upcoming Gmail Labs
> apps!
>
> j/k :)
>
> FK
>

> On Thu, Feb 25, 2010 at 7:42 PM, Alister Scott <alister.sc...@gmail.com>wrote:
>
> > It makes sense to get rid of the Gmail example, because why you would
> > ever want to automated a GUI to send an email is the question.
> > It is *so* easy to send an email through ruby itself.
>
> > On Feb 24, 7:56 pm, Željko Filipin <zeljko.fili...@wa-research.ch>
> > wrote:
> > > On Tue, Feb 23, 2010 at 9:12 PM, Bill Agee <billa...@gmail.com> wrote:
> > > > I suggest we remove the gmail wiki page.
>
> > > Done.
>
> > > Željko
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Watir General" group.
> > To post to this group, send email to watir-...@googlegroups.com
> > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > To unsubscribe from this group, send email to

> > watir-genera...@googlegroups.com<watir-general%2Bunsu...@googlegroups.com>

Željko Filipin

unread,
Feb 26, 2010, 4:08:39 AM2/26/10
to watir-...@googlegroups.com
On Fri, Feb 26, 2010 at 5:01 AM, Alister Scott <aliste...@gmail.com> wrote:
> Or spammers might be using Watir to spam the world :(

There's an app for that :)

http://github.com/mikel/mail

Željko
Reply all
Reply to author
Forward
0 new messages