mmaction on a DIV link

350 views
Skip to first unread message

Gustavo Godoy

unread,
Aug 15, 2008, 12:55:32 PM8/15/08
to Watir General
Hi,

i´m having a problem with a link inside a DIV.
It´s a menu built inside a DIV, and his attrbute onclick returns null.
The action is in attribute 'mmaction', but watir doesn´t understand
this 'mmaction' attribute.

when I use:
ie.div(:id, "menuItem1").flash

the link flashes.

When I use this:
ie.div(:id, "menuItem1").fire_event("onclick")

nothing happens, because "onclick returns null
This is the element in the source
... onclick="onMenuItemAction(null,this);" saveColor="#F1F1F1"
menuHiliteBgColor="#CCCCCC"
mmaction="location='javascript:openWin(2);'" zIndex="1">

The action is in 'mmaction' attribute.

Tks

Gustavo Godoy
Brasil


wesley chen

unread,
Aug 16, 2008, 9:13:00 AM8/16/08
to watir-...@googlegroups.com
I think you'd better provide your code here.
--:)
Man should be hard to himself, but tolerant to others.

Gustavo Labbate Godoy

unread,
Aug 20, 2008, 7:40:06 AM8/20/08
to watir-...@googlegroups.com
here are the code from the link, get from IE developer toolbar:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Transitional//EN"><META
http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<HTML lang="en-US" xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-US"><BODY scroll="no"><DIV id="menuLayer1"
style="Z-INDEX: 1; LEFT: -200px; VISIBILITY: hidden; WIDTH: 142px;
COLOR: #f1f1f1; POSITION: absolute; TOP: -200px; HEIGHT: 103px;
BACKGROUND-COLOR: #f1f1f1; zindex: 1; pixeltop: -300; pixelleft:
-300"><DIV id="menuLite1" style="Z-INDEX: 1; LEFT: 1px; WIDTH: 140px;
POSITION: absolute; TOP: 1px; HEIGHT: 101px; BACKGROUND-COLOR:
#f1f1f1" onmouseout="mouseoutMenu();"><DIV id="menuFg1" style="LEFT:
1px; WIDTH: 139px; POSITION: absolute; TOP: 1px; HEIGHT: 100px;
BACKGROUND-COLOR: #999999">

############################################
This is the link that uses a 'mmaction' to do the action
Pay attention on 'onclick' action, that returns 'null'.
The action is in 'mmaction', and watir doesn´t understand it.
############################################

<DIV id="menuItem1" onmouseover="onMenuItemOver(null,this);"
style="FONT-SIZE: 10px; LEFT: 0px; VISIBILITY: inherit; WIDTH: 138px;
CURSOR: hand; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
POSITION: absolute; TOP: 20px; HEIGHT: 19px; BACKGROUND-COLOR:
#f1f1f1; fontSize: 10px" onclick="onMenuItemAction(null,this);"
saveColor="#F1F1F1" menuHiliteBgColor="#CCCCCC"
mmaction="location='javascript:openWin(2);'" zIndex="1">
<DIV id="menuItemText1" style="LEFT: 5px; COLOR: #000000; POSITION:
absolute; TOP: 3px">
<DIV id="menuItemShim1" style="LEFT: 0px; POSITION: absolute; TOP: 0px">
<DIV align="left">
EMPRESAS
</DIV>
</DIV>


############################################
End of the link
############################################


&nbsp;
</DIV>
<DIV id="menuItemHilite1" style="LEFT: 5px; VISIBILITY: hidden; COLOR:
#000000; POSITION: absolute; TOP: 3px">
<DIV id="menuItemShim1" style="LEFT: 0px; POSITION: absolute; TOP: 0px">
<DIV align="left">
EMPRESAS
</DIV>
</DIV>
&nbsp;
</DIV>
</DIV>

</DIV></DIV></DIV></BODY></HTML>





2008/8/16 wesley chen <cjq...@gmail.com>

Tim Koopmans

unread,
Aug 20, 2008, 10:24:14 AM8/20/08
to Watir General
Ok, think I follow. So fire_event won't work for you here as you have
non-standard javascript events defined.

I've cleaned up and provided a simplified version of the html here:
http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0020.html

Then, using the .goto method, I am simply calling the javascript
function direct (that mmaction would normally call) as follows:
@b.div(:id, "menuItem1").flash # pass
#@b.div(:id, "menuItem1").fire_event("mmaction") # fail
#Previous action will cause WIN32OLERuntimeError: fireEvent Invalid
argument.

@b.goto("javascript:openWin(2)") # pass

So let me know if that last call is suitable. You may want to enum the
function call into a variable using regex (if it is dynamic/changing)

Regards,
Tim Koopmans

Gustavo Labbate Godoy

unread,
Aug 20, 2008, 11:31:53 AM8/20/08
to watir-...@googlegroups.com
Tim,
thanks

it´s works

I will implement a way to get the value in the 'mmaction' and then the
goto wil call it.

thanks again...

Gustavo Godoy
Brasil


2008/8/20 Tim Koopmans <tim....@gmail.com>:

Gustavo Labbate Godoy

unread,
Oct 8, 2008, 2:01:12 PM10/8/08
to watir-...@googlegroups.com
Tim,

Sorry to answer with another question.
I was implementing the solution you pass to me, but i found something I cant resolve.
When I pass the browser.goto("javascript:openWin(i)") command, the script will not "close" until the browser is closed.
It´s get stucked in the line of the command. So, if I pass some button.click command, it will not work.

What i´m doing wrong?


Gustavo Godoy
Brasil

juuser

unread,
Oct 10, 2008, 6:17:42 AM10/10/08
to Watir General
for example, execute it in some separate thread then like this:

Thread.start {browser.goto("javascript:openWin(i)") }

and have some wait_until after that line to check if you can do
anything yet...
Reply all
Reply to author
Forward
0 new messages