IEAuto.dll ExtractTagByname

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

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

IEAuto.dll ExtractTagByname

Post by SteenJakobsen » Thu Jun 10, 2010 9:11 am

Hi marcus,

I'm having trouble extracting data form a given tag by using its name.
I'm not to experienced in this so maybe its just basic know how :-)

Here is what i'm doing:

This works fine:

Code: Select all

Let>INPUT2_SIZE=4098
LibFunc>hIE,ExtractTag,r,%IE[0]%,,INPUT,2,0,INPUT2
MidStr>r_6,1,r,INPUT2
Now I want to extract tyhe same field but not by its index but by it name.
This does not work: (I have tried many differnt argument combinations)

Code: Select all

Let>divside_SIZE=4098
LibFunc>hIE,ExtractTagByName,r,%IE[0]%,INPUT,,{"username"},0,mydata
MidStr>r_6,1,r,mydata

I can put text into the field by using this command - and it works just fine

Code: Select all

LibFunc>hIE,FormFill,r,%IE[0]%,{""},{"loginform"},{"username"},%[<Login_BrugerNavn>]%,0

Any feedback is most apreciated :-)
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Thu Jun 10, 2010 3:17 pm

Try:

Let>mydata_SIZE=4098
LibFunc>hIE,ExtractTagByName,r,IE[0],,INPUT,username,0,mydata
MidStr>r_6,1,r,mydata

If it does not work please send the source of the page.
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 » Fri Jun 11, 2010 8:32 am

Hi Marcus,

It did not work ..

Basically what I want to to is to make sure that the data that I assign to the field using FormFill is acctually accepted by the page.
The biggest problem (as I se it )in automating the differnt apps (including IE) is timming. And it is very important to have routines that check and double check that the apps have recieved the data. So what I'm trying to write is a generic FormFill SRT that can assign data to a field and verify the the field has actualley recieved the data.

If you have an exmaple or some add-on library that I can purchace then
I'm all ears :-)


Here is my macro code:

Code: Select all

LibFunc>hIE,CreateIE,IE[0],0

LibFunc>hIE,Navigate,r,%IE[0]%,http://labka.serv.hosp.dk:7003/LabkaII/login.jsp
LibFunc>hIE,WaitIE,r,%IE[0]%

// Afdeling
LibFunc>hIE,FormFill,r,%IE[0]%,{""},{"loginform"},{"wardCode"},%[<Login_Afdeling>]%,0
LibFunc>hIE,WaitIE,r,%IE[0]%
// Klik på "Vis" til at finde afdelingen
LibFunc>hIE,ClickTag,r,%IE[0]%,{""},{"loginform"},BUTTON,ID,searchBtn
Wait>1
LibFunc>hIE,ContainsText,exists,%IE[0]%,{""},Afdeling findes ikke
If>exists=1
   GoSub>DMExit,Error:Fejl i afdelingsoplysninger:%[<Login_Afdeling>]%
EndIf

// Brugernavn & kodeord
LibFunc>hIE,FormFill,r,%IE[0]%,{""},{"loginform"},{"username"},%[<Login_BrugerNavn>]%,0
LibFunc>hIE,FormFill,r,%IE[0]%,{""},{"loginform"},{"password"},%[<Login_kodeord>]%,0

**breakpoint**
Let>mydata_SIZE=4098
LibFunc>hIE,ExtractTagByName,r,IE[0],,INPUT,username,0,mydata
MidStr>r_6,1,r,mydata
And here is the source form the web page:

Code: Select all


<DOCTYPE>

<html>
<head>
    <script>
        //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>
    <meta>
    <link>
</head>

<body>
<script></script>
<script></script>
<script></script>
<script></script>
<script></script>
<script>
    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></script>

<div>

    <h1>LABKA II indlogning</h1>
    

    <form>

        <table><tr><td>
        <table>
            <tr>
                <td><a>Hjælp</a>
                    <script>
                        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>Afdeling</td>
                    <td><input></td>
                    <td><button>V<SPAN>i</SPAN>s</button></td>
                    <td><input></td>
                </tr>
                <tr>
                    <td>Brugernavn</td>
                    <td><input>
                    </td>
                </tr>
                <tr>
                    <td>Password</td>
                    <td><input></td>
                </tr>
                <tr>
                    <td>
                        <button><SPAN>L</SPAN>og ind</button>
                    </td>
                </tr>
            </table>
        </td></tr></table>
        <input>
        <input>
    </form>
</div>
</body>
</html>
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Fri Jun 11, 2010 8:42 am

ExtractTag returns the text between the opening and closing tags for an element, or the html between them. But this isn't how input fields work.

The text you enter is assigned to the field's value property, not the text between the opening and closing tags like in an A element. (Input doesn't have a closing tag).

So ExtractTag/ExtractTagByName will not help you here.

To do this we need a new function that will retrieve the value of an input field.
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 » Fri Jun 11, 2010 10:36 am

Hi Marcus,

I understand.

Normally I do not need to read the values of input fields but as I described earlier the purpose is to be able to verify the the browse actually has received the value assigned using FormFill.
As it is now I have to insert Wait>3 but often wait is not necessary.
So it is just a precaution to make sure the macro is stable.

The best thing would be to be able to detect when the filed has received the data - Is that possible?

In standard windows Java-Swing apps we do the same verification using CTRL-A and CTRL-C and then verifying that the data in the clipboard is the same as the data we send to the field using SendText>

So basically what I'm looking for is some code that can make my Macros more reliable with regard to sending text to fields.

I hope you can help me as I'm facing some very slow macros that have to wait a lot of time just in case the data did not make it to the fields. Also
it would be great to write macros that I can trust so that a slow machine or
internet connection will not break the whole system .. ;-)
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 » Tue Jun 15, 2010 4:48 am

Hi Marcus,

Do you have any hint to me for writing safe and stable macros with regard to making sure that input fields actually have received the text that I assign to them using the function FormFill ?

As it is now I just have to "hope" that it is ok and then blindly continue the macro.

Thanks :-)
Best Regards
Steen Jakobsen
DM Software A/S

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Extract form input fields by value with VBScript

Post by adroege » Tue Jun 15, 2010 1:36 pm

Here is a VERY simple example of how to read a form field from a webpage. This script will open to Google. (Of course Google sometimes changes their home page, but most likely not before you get a chance to test this) Type something into the search box (which is an input field in a form), and then when you dismiss the MessageModal dialog, the VBScript will extract the value of that form variable and show it to you.

Code: Select all

VBSTART
  Dim IE

Sub CreateIE
  Set IE = CreateObject("InternetExplorer.Application")
  IE.visible = 0
End Sub

Sub MakeIEVisible(visible)
  IE.visible = visible
End Sub

Sub Navigate(URL)
  IE.navigate URL
End Sub

Sub WaitBusy
  do while IE.Busy
  loop
End Sub

Sub DestroyIE
  IE.Quit
  Set IE = Nothing
End Sub

Function MyGet ()
  'In Google the form is named "f" and the input box is named "q"
  MyGet=IE.document.f.q.value
End Function

VBEND

  VBRun>CreateIE
  VBRun>MakeIEVisible,1

  VBRun>Navigate,http://www.google.com/
  VBRun>WaitBusy
  MessageModal>Type something into the Google search field, then press OK

  VBEval>myGet(),result
  MessageModal>You are searching google for %result%
  VBRun>DestroyIE


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

Post by SteenJakobsen » Wed Jun 16, 2010 11:19 am

Hi,

Thanks for your feedback.
I’m using LibFunc to do the automation and therefore I cannot use your example.
I was hoping for Marcus to maybe provide a solution maybe as an enhanced ForFill method
That checks that the field actually has received the data.


The point is that it is difficult to write stable and robust macros since there is very little control over what is happening when fields are assigned some data.
It would be great if the return value ONLY was true when the operation succeeded and the filed referenced in FormFill actually was assigned the value specified.
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Wed Jun 16, 2010 12:25 pm

A new function to retrieve the value of form elements is on the to do list.
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 » Thu Jun 17, 2010 5:06 am

Wonderful :-) .. then I can write a secure SRT to do the assignment.
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Thu Jun 24, 2010 2:17 pm

Steen,

Just realised: ExtractTag DOES already retrieve an input field's VALUE property. But ExtractTagByName is not doing the same.

So all we actually need to do is to fix ExtractTagByName to work the same way as ExtractTag. We're working on it.
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 » Fri Jun 25, 2010 4:49 am

Great :-)
Best Regards
Steen Jakobsen
DM Software A/S

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

Post by Marcus Tettmar » Mon Jun 28, 2010 10:40 am

A WebRecorder update (with IEAuto.DLL 2.07) is now available which fixes ExtractTagByName to retrieve the value of form fields in the same way as ExtractTag. You can get it from the registered user area.
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 Jun 28, 2010 10:58 am

That is just GREAT :-)
Best Regards
Steen Jakobsen
DM Software A/S

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