How to click button using webrecorder 2.3 /IEAuto.dll v12

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

How to click button using webrecorder 2.3 /IEAuto.dll v12

Post by SteenJakobsen » Thu May 20, 2010 7:23 pm

Hi,

Using IEAuto.dll (webrecorder)

How can I click this button : ?? :-)

Code: Select all

                <tr>
                    <td align="right" colspan="4">
                        <button tabIndex="5"
                                title="Log ind"
                                id="loginbtn" class="loginbtn" defaultButton=true
                                
                                onclick="login()"
                                
                                ><SPAN STYLE='text-decoration: underline'>L</SPAN>og ind</button>
                    </td>
                </tr>



I have tried and tried..
My best guess is: (however it does not work)

Code: Select all

Let>FrameName={""}
Let>FormName={"loginform"}
Let>TagValue={"loginbtn"}
LibFunc>hIE,ClickTag,r,%IE[0]%,str:FrameName,str:FormName,A,NAME,str:TagValue
This pice of code filling the password field works just fine.

Code: Select all

Let>FrameName={""}
Let>FormName={"loginform"}
Let>FieldName={"password"}
Let>FieldValue={"mypass"}
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0
Best Regards
Steen Jakobsen
DM Software A/S

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Fri May 21, 2010 3:41 am

Hi again,

This is the complete source form the page and the button I want to
click is : id="loginbtn" class="loginbtn"

Any one .. please .. ;-)

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">





<html>
<head>
    <script type="text/javascript">
        //code to prevent opening login page in a modal dialog.
        if (window.dialogArguments != null) {
            window.returnValue = "relogon";
            window.close();
        }

        //code to prevent opening login page in a frame.
        if (top.location != self.location) {
            top.location = self.location;
        }
    </script>
    <title>LABKA II indlogning</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Cache-control" content="no-cache">
    <link rel="stylesheet" type="text/css" href="style/login.css">
</head>

<body onload="onLoad()" scroll="auto">
<script type="text/javascript" src="/LabkaII/js/prototype.js"></script>
<script type="text/javascript" src="/LabkaII/js/common.js"></script>
<script type="text/javascript" src="/LabkaII/js/button.js"></script>
<script type="text/javascript" src="/LabkaII/js/taborder.js"></script>
<script type="text/javascript" src="/LabkaII/js/shortcut.js"></script>
<script type="text/javascript">
    var shortcutManager = new ShortcutManager();
    shortcutManager.addShortcut("alt+l","document.all('loginbtn').click();", "");
    shortcutManager.addShortcut("alt+i","document.all('searchBtn').click();", "");
    shortcutManager.addShortcut("enter", "doDefaultAction('loginbtn')", "");
    document.onkeydown = shortcutManager.keyEventListener;

    window.returnValue = "relogon";

    var _WARD_NAME = "Geriatrisk Sengeafsnit, M2";
    var _WARD_CODE = "m2(fh)";

    function onLoad(){
        //description: Method is called during of onLoad event handling.
        //           It is used to perform client side initialization.
        setListDisableControls();
        attachTabOrderEvent();       

        contentContainer.style.display = 'block';
        checkCodeAndName(trim(loginform.wardCode.value), trim(loginform.wardName.value), _WARD_CODE, _WARD_NAME);

        if (document.all("wardName").value == "") {
            document.all("wardCode").focus();
            document.all("username").disabled = true;
            document.all("password").disabled = true;
        } else {
            document.all("username").focus();
        }
    }

    window.navigator.loggedProperty = LOGGED_PROP_VALUE;

    document.cookie = "PATH=/";

</script>
<noscript>
    <h1>Error screen:</h1><br>
    <b>Please turn on JavaScript support.</b>
</noscript>

<script type="text/javascript" src="login.js"></script>

<div width="100%" hight="100%" style="display: none" id="contentContainer">

    <h1 align="center">LABKA II indlogning</h1>
    

    <form method="post" name="loginform" id="loginform">

        <table width="200" border="0" cellspacing="0" cellpadding="10" align="center" class="loginform"><tr><td>
        <table width="100%" border="0" cellspacing="0" cellpadding="3" align="center">
            <tr>
                <td colspan="5" align="right"><a href="#" onclick="showHelp(); return false;">Hjælp</a>
                    <script type="text/javascript">
                        function showHelp() {
                            var md=showModalDialog('loginhelp.html','','status=0,title=0,resizable=no,scrollbars=no,dialogWidth=300px,dialogHeight=100px');
                        }
                        window.onhelp = showHelp;
                    </script>
                </td>
            </tr>
            <tr>
                    <td nowrap>Afdeling</td>
                    <td><input id="tfWardCode" type="text" tabIndex="1" name="wardCode" class="wardcode" maxlength="40" value="m2(fh)"
                               
                               title="Indtast din afdelingskode
m2(fh)"
                               onkeydown="this.valueBeforeTyping = this.value"
                               onkeyup="checkCodeAndName(trim(this.value), trim(wardName.value), _WARD_CODE, _WARD_NAME);
                   updateRelatedControlText('tfWardCode', '[tfWardName]')" oncut="setTimeout(this.onkeyup, 50)" onpaste="setTimeout(this.onkeyup, 50)"
                                                                         valueOnLoad="m2(fh)"
                            /></td>
                    <td><button class="wardbtn" tabIndex="2"
                                title="Vis afdelingsnavn"
                                onclick="getWard()"
                                id="searchBtn">V<SPAN STYLE='text-decoration: underline'>i</SPAN>s</button></td>
                    <td><input id="tfWardName" type="text" name="wardName" class="wardname" size="10" value="Geriatrisk Sengeafsnit, M2" tabIndex="-1"
                               title="Afdelingens navn"
                               readonly valueOnLoad="Geriatrisk Sengeafsnit, M2"></td>
                </tr>
                <tr>
                    <td nowrap>Brugernavn</td>
                    <td colspan="4"><input type="text" id="username" name="username" size="40" maxlength="40" class="loginfield" value="FROS0003"
                                           title="Brugernavn" tabIndex="3">
                    </td>
                </tr>
                <tr>
                    <td nowrap>Password</td>
                    <td colspan="4"><input type="password" id="password" name="password" size="40" maxlength="40" class="loginfield"
                                           tabIndex="4"
                                           title="Password"
                                           value=""></td>
                </tr>
                <tr>
                    <td align="right" colspan="4">
                        <button tabIndex="5"
                                title="Log ind"
                                id="loginbtn" class="loginbtn" defaultButton=true
                                
                                onclick="login()"
                                
                                ><SPAN STYLE='text-decoration: underline'>L</SPAN>og ind</button>
                    </td>
                </tr>
            </table>
        </td></tr></table>
        <input type="hidden" name="timezoneOffWinter" value=0>
        <input type="hidden" name="timezoneOffSummer" value=0>
    </form>
</div>
</body>
</html>
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 21, 2010 9:08 am

The button just fires the login() function. So just call it directly:

LibFunc>hIE,Navigate,r,%IE[0]%,Javascript:login()
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Sun May 23, 2010 5:30 am

I'm a newbie to html ..

I think that your quick and relevant respon to the posts here are critical and GREAT.


Again Marcus THANKS :-)

p.s.
I think that your kjabascript example shuld go into your doc's

pps But to a later case .. how do I click a button ?
Best Regards
Steen Jakobsen
DM Software A/S

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon May 24, 2010 11:42 am

Hi again,

Marcus - I can not figure out how do I click a button. Now I have 2 more cases and the nice javascript trick you gave me can not be used here.

Is there a way for webrecorder to detect that a button i beeing clicked ?
Or do you have some code example for clicking a button? :?:
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon May 24, 2010 1:24 pm

Use the ClickTag function.

E.g. for the following button taken from the source you posted:

[code]Vis[/code]

You can use:

LibFunc>hIE,ClickTag,r,IE[0],,,BUTTON,TEXT,Vis

The text inside is "Vis" so I've used that.

But since your button also has an ID you could use it instead:

LibFunc>hIE,ClickTag,r,IE[0],,,BUTTON,ID,searchBtn
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon May 24, 2010 8:24 pm

Hi Marcus,

IT WORKS :-)


The trick was also to specify the frame and form arguments.

This is just beutiful ..

Tkanks - Steen
Best Regards
Steen Jakobsen
DM Software A/S

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts