Jump to content
dnnytn

How to Click on Javascript / Dojo TreeNode on Webpage

Recommended Posts

dnnytn

Hi Everyone, due to email system migration, I am trying to automate the email forwarding per account basis on webmail. The action required for each user is:

1. Logging in to webmail for the user

2. Click on the "Options" link

3. On the pop-up box, click on "Mail", then "Forwarding" (Screen shot provided)

4. Followed by keying in the forwarding details. 

I am stuck on step 3. It appears that the links for "Mail" and "Forwarding" are javascript and not real links. I do not have any programming and development experience and just started with AutoIT 2 weeks back just for this specific task. 

The source for the page is here, it looks like the part that i should be focusing on is : 

 

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Strict//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>
<head>
  <meta http-equiv='X-UA-Compatible' content='IE=EmulateIE7'>
  <title>WebMail - Corporate Edition - Options</title>
  
  <link rel='stylesheet' type='text/css' href='/extras/dojo/dojo1.4.3/dojox/grid/resources/Grid.css'>
  <link rel='stylesheet' type='text/css' id='tundraGrid' href='/extras/dojo/dojo1.4.3/dojox/grid/resources/tundraGrid.css'>

  
  <meta http-equiv='X-UA-Compatible' content='IE=EmulateIE7'>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
  <script type='text/javascript'> 
  try{ 
  document.execCommand('BackgroundImageCache', false, true); 
  }catch(e){} 
  </script>   
  
<link rel='stylesheet' type='text/css' href='/extras/dojo/dojo1.4.3/dojo/resources/dojo.css'>
<link rel='stylesheet' type='text/css' id='tundra' href='/extras/dojo/dojo1.4.3/dijit/themes/tundra/tundra.css'>
<style type='text/css'>
  html, body, pre, input,
  .dijitTextBox,
  .dijitComboBox,
  .dijitMenuItem,
  .dijitSpinner,
  .dojoxGrid,
  .dijitTextArea {
     font-family:  'Lucida Grande', Tahoma, Arial, Helvetica, sans-serif !important;
  }
  .miraLoadingImg { background: url('/extras/dojo/dojo1.4.3/dojox/image/resources/images/loading.gif'); }
  .tundra .miraToolbar { background:url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/titleBar.png') repeat-x top left !important; }
  .tundra .miraNoSortHeader:hover { background:url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; } 
  .tundra .miraNoSortHeader {background:url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; } 
  .tundra .dojoxGridHeader th {background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; border-top:0px !important; }
  
  .soria .miraNoSortHeader:hover{ background:url('/extras/dojo/dojo1.4.3/dijit/themes/soria/images/titleBar.png') repeat-x top left; }
  .soria .miraToolbar { background:#eaeaea url('/extras/dojo/dojo1.4.3/dijit/themes/soria/images/titleBar.png') repeat-x top left; }

  .nihilo .miraNoSortHeader:hover{ background:url('/extras/dojo/dojo1.4.3/dijit/themes/nihilo/images/titleBar.png') repeat-x top left; }
  .nihilo .miraToolbar { background:#eaeaea url('/extras/dojo/dojo1.4.3/dijit/themes/nihilo/images/titleBar.png') repeat-x top left; }
  .nihilo .dojoxGridHeader .dojoxGridCell{background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; }
  .nihilo .dijitTitlePaneTitle{background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; }                   
  .nihilo .dijitToolbar{background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; }
  .nihilo .dojoxGridHeader th{background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important;
    border-top:0px!important;   
     }
  .dojoxGridMasterHeader {background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/tabEnabled.png') repeat-x top left !important; }
  .dojoxGridHeader th{background:#E9E9E9 url('/extras/dojo/dojo1.4.3/dijit/themes/soria/images/titleBar.png') repeat-x top left !important;
    border-top:0px!important;   
     }
    
    
  .miraPlus { 
    background-image:url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/plusButton.gif'); 
    background-repeat: no-repeat;
    text-align: center;
    vertical-align: middle;
    width: 16px;
    height: 16px;
  }
  .miraMinus { 
    background-image:url('/extras/dojo/dojo1.4.3/dijit/themes/tundra/images/minusButton.gif'); 
    background-repeat: no-repeat;
    text-align: center;
    vertical-align: middle;
    width: 16px;
    height: 16px;
  }
  .miraClose { 
    background-image:url('/extras/dojo/dojo1.4.3/dojox/image/resources/images/close.png');
    background-repeat: no-repeat;
    text-align: center;
    vertical-align: middle;
    width: 16px;
    height: 16px;
  }
  p font {line-height: 120%;}
  h1 font {line-height: 120%;}
  h2 font {line-height: 120%;}
  h3 font {line-height: 120%;}
  h4 font {line-height: 120%;}
  h5 font {line-height: 120%;}
  h6 font {line-height: 120%;}
</style>

 
<script type='text/javascript' src='/extras/dojo/dojo1.4.3/dojo/aggregate_dojo.js' 
        djConfig='isDebug: false, debugAtAllCosts: false,  parseOnLoad: true, usePlainJson: true, 
        baseUrl: "/extras/dojo/dojo1.4.3/dojo/", 
        locale:"en-us", extraLocale: ["en-us"]'></script> 

<script type='text/javascript' src='/extras/dojo/dojo1.4.3/dojo/ce.js'></script>

  
<style type='text/css'>
.gen_silk_icon {
  background-image: url(/wm/eml/icons/silk_imagemap.png?locale=en_US.ISO_8859-1&ui_ver=4.3.7-GA.5&brand=system&deldom=);
  background-repeat: no-repeat;
  width: 16px;
  height: 16px;
  text-align: center;
  vertical-align: middle;
}

.miraLogo {
  background-image: url(/wm/eml/icons/lhs_banner_logo.gif?locale=en_US.ISO_8859-1&ui_ver=4.3.7-GA.5&brand=system&deldom=);
  background-repeat: no-repeat;
  background-position: center center;
  width: 100%;
  height: 100%;
}

.handle {
  background-image: url(/wm/eml/icons/handle.png?locale=en_US.ISO_8859-1&ui_ver=4.3.7-GA.5&brand=system&deldom=);
  background-repeat: repeat-y;
  background-position: 0px 0px;
}

.genInfoSplitter {
  background-image: url(/wm/eml/icons/info_card_splitter.gif?locale=en_US.ISO_8859-1&ui_ver=4.3.7-GA.5&brand=system&deldom=);
  background-repeat: repeat-x;
  background-position: bottom;
  background-color: transparent;
  height: 4px;
  width: 100%;
  margin: 0px;
  padding: 0px;
}

.mcalFreeBusyGridInvalidRow {
  background-image: url(/wm/eml/icons/calendar_freebusy_invalid.gif?locale=en_US.ISO_8859-1&ui_ver=4.3.7-GA.5&brand=system&deldom=);
  position: absolute;
  border-width: 1px 1px 1px 1px;
  border-style: solid;
  border-color: #dddddd;
  z-index: 3;
  height: 19px;
}
</style>

  <link rel='stylesheet' type='text/css' id='system-default' href='/wm/eml/extras/css/aggregated_css/uui_system-default.css?ui_ver=4.3.7-GA.5&locale=en_US.ISO_8859-1&brand=system&deldom='>
  
  <link rel='SHORTCUT ICON' href='/wm/eml/icons/mirapoint.ico?locale=en_US.ISO_8859-1&ui_ver=4.3.7-GA.5&brand=system&deldom='>
  <script type='text/javascript' src='/wm/eml/eui.js?ui_ver=4.3.7-GA.5&locale=en_US.ISO_8859-1&brand=system&deldom='></script>
  
<script type='text/javascript'>
<!-- 
if (typeof __mainWindow__ != 'undefined' && __mainWindow__.__debug__) __include__('/wm/eml/debug.js'); 
//-->
</script>


<script type='text/javascript'>
<!--
    // dojo widgets, handles, etc.
    var model = null, tree = null, 
    stores = {},
    connects = [],
    lhs_item = null,
    anyone_perm_item = null,
    opt_change_ui_cb = dojo.hitch(eUI, 'opt_change_ui'),
    options_items = [];

    
options_items.push({
    'id'        : 'general',
    'label'     : localevar.get('General'),
    'url'       : null,
    'toplevel'  : true,
    'noselect'  : true
});

    

options_items.push({
    'id'    :   'popt_personal',
    'label' :   localevar.get('Account'),
    'url'   :   '/wm/eml/popt_personal.html',
    'pName' :   'general'
});


options_items.push({
    'id'    :   'changepass',
    'label' :   localevar.get('Change Password'), 
    'url'   :   '/cgi-bin/euadmin.cgi/eup/changepass.html',
    'pName' :   'general'
});


options_items.push({
    'id'    :   'popt_colortheme',
    'label' :   localevar.get('Color Theme'), 
    'url'   :   '/wm/eml/popt_colortheme.html',
    'pName' :   'general'
});


options_items.push({
    'id'    :   'popt_aboutpage',
    'label' :   localevar.get('About'), 
    'url'   :   '/wm/eml/popt_aboutpage.html',
    'pName' :   'general'
});


    
options_items.push({
    'id'        : 'mail',
    'label'     : localevar.get('Mail'),
    'url'       : null,
    'toplevel'  : true,
    'noselect'  : true
});

    

options_items.push({
    'id'    :   'mopt_general',
    'label' :   localevar.get('Settings'), 
    'url'   :   '/wm/eml/mopt_general.html',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'mopt_composing',
    'label' :   localevar.get('Composing'), 
    'url'   :   '/wm/eml/mopt_composing.html',
    'pName' :   'mail'
});


options_items.push({
    'id'        :   'autoreply',
    'label'     :   localevar.get('Auto-Reply'), 
    'url'       :   '/cgi-bin/euadmin.cgi/eup/autoreply.html',
    'pName'     :   'mail'
});


options_items.push({
    'id'    :   'forward',
    'label' :   localevar.get('Forwarding'), 
    'url'   :   '/cgi-bin/euadmin.cgi/eup/forward.html',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'mopt_signature',
    'label' :   localevar.get('Signature'), 
    'url'   :   '/wm/eml/mopt_signature.html',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'getmail',
    'label' :   localevar.get('External Mail'), 
    'url'   :   '/cgi-bin/euadmin.cgi/eup/getmail.html',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'whitelist',
    'label' :   localevar.get('Allowed Senders'), 
    'url'   :   '/wm/eml/mopt_uce.html?ucetype=wl',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'blacklist',
    'label' :   localevar.get('Blocked Senders'), 
    'url'   :   '/wm/eml/mopt_uce.html?ucetype=bl',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'whitelistto',
    'label' :   localevar.get('Allowed Mailing Lists'), 
    'url'   :   '/wm/eml/mopt_uce.html?ucetype=recipwl',
    'pName' :   'mail'
});


options_items.push({
    'id'    :   'contfilt_adv',
    'label' :   localevar.get('Message Filters'), 
    'url'   :   '/cgi-bin/euadmin.cgi/eup/contfilt_adv.html',
    'pName' :   'mail'
});


    
options_items.push({
    'id'    :   'calendar',
    'label' :   localevar.get('Calendar'),
    'url'   :   null,
    'toplevel'  :   true,
    'service'   :   'calendar',
    'noselect'  :   true
});

    

options_items.push({
    'id'    :   'prefs_gen',
    'label' :   localevar.get('Presentation'), 
    'url'   :   '/mc/ecal/prefs_gen.html',
    'pName' :   'calendar'
});


options_items.push({
    'id'    :   'reminders',
    'label' :   localevar.get('Reminders'), 
    'url'   :   '/mc/ecal/reminders.html',
    'pName' :   'calendar'
});


options_items.push({
    'id'        :   'permissions',
    'label'     :   localevar.get('Sharing Controls'), 
    'url'       :   '/mc/ecal/permissions.html',
    'service'   :   'group_calendar',
    'pName'     :   'calendar'
});


options_items.push({
    'id'        :   'prefs_publish',
    'label'     :   localevar.get('Publish'), 
    'url'       :   '/mc/ecal/prefs_publish.html',
    'service'   :   'group_calendar',
    'pName'     :   'calendar'
});


    


options_items.push({
    'id'    :   'downloads',
    'label' :   localevar.get('Downloads'),
    'url'   :   null,
    'noselect'  :   true,
    'toplevel'  :   true
});

options_items.push({
    'id'    :   'download_ConnectR',
    'label' :   localevar.get('ConnectR for Outlook'), 
    'url'   :   '/mc/ecal/download_ConnectR.html',
    'pName' :   'downloads'
});





    dojo.addOnLoad(function(){
        stores.lhs = new dojo.data.ItemFileWriteStore({  data: { identifier:   'id',
                                 label:        'label',
                                 items:        eUI.prepareTree(options_items)
                              }
                              });
                            

        model = new dijit.tree.ForestStoreModel({
                                        store: stores.lhs,
                                        query: {toplevel:true},
                                        rootId: "options_root",
                                        childrenAttrs: ["children"]
                                });

        tree = new mira.Tree({
                                    model:      model,
                                    showRoot:   false,
                                    persist:    true,
                    id:         "options_tree"
                                   },
                                   document.getElementById("options_tree_here"));

        tree.startup();

    if (__mainWindow__.prefsMgr.haveService('group_calendar')) {
        stores.permissions = new mira.DataStore({
                            data:   {   identifier:'id',
                    label:'label',
                    items: []}
                    });
    }

        connects.push(dojo.connect(tree, "onClick", eUI, eUI.options_click));    

    eUI.popupLoaded();
    __mainWindow__.prefsMgr.go(eUI, options_items[1]);
    });

//-->
</script>
</head>
<body class="miraPopup tundra" onunload='eUI.eup_unload();'>
<div class="miraPreloader miraLoadingImg" id="mira_preloader"></div>
<div id ="mira_standby" target="opt_rhs" dojoType="dojox.widget.Standby" color="#eeeeee" zIndex="12000"></div>
<div dojoType="dijit.layout.BorderContainer" design="sidebar" style="height:100%;width:100%; overflow:hidden;" gutters="true">
    <div dojoType="dijit.layout.ContentPane" region="left" style="width:225px;" splitter="true">
    <div class="genTitle" style="width:100%;">Options</div>
    <div id="options_tree_here"></div>
    </div>
    <div dojoType="dijit.layout.ContentPane" id="opt_rhs" region="center" style="" onLoad="eUI.options_rhs_loaded();">
    </div>
</div>
</body>
</html>

It seems like the part i should be focusing on is here:

options_items.push({
    'id'    :   'forward',
    'label' :   localevar.get('Forwarding'), 
    'url'   :   '/cgi-bin/euadmin.cgi/eup/forward.html',
    'pName' :   'mail'
});

After searching the forum and reading the help file, I have attempted at least the following: 

1. _IENavigate - fail as the URL is special for each logged in session

2. _IELinkClickByText - failed as no link is found ( i used _IELinkGetCollection = 0 link found)

3. IETableGetCollection - only found 2 tables and its only for the right hand pane of the page. 

4. IEPropertyGet 'innertext' - no errors, but no clicking actions

5. _IETagNameAllGetCollection - Found Tagname: DIV, ID: dijit__TreeNode_10, innertext: * Forwarding but not able to use these information to get autoit to click.

6. _IEImgGetCollection - Found 41 instances of *blank.gif, tried to randomly click an index of gif, but no visible actions being done. 

 

My code is here, it is heavily commented out by the past attempts, so it must be hard to read, apologies in advance. The trouble begins at line 82. Any help or advice is greatly appreciated.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Danny

 Script Function:
    Automate Mirapoint Forwarding PER user basis. THis needs to run for each
    user that is migrating

#ce ----------------------------------------------------------------------------
#include <IE.au3>
#include <MsgBoxConstants.au3>
;~ #include <Array.au3>

Global $i = 0

If $i = 7 Then
   MsgBox(0, "Rerun", "Lets try that again. Ensure that values are correctly entered")
EndIf

;~ MsgBox(0, "Notice", "System will now help you to forward your mails. Please key in your account information and do not interrupt the process")
;Get Email Address from user
Global $EmailAddr = "username@olddomain.com"

; Asks the user to enter a password.
Global $Password = "passwordentered"

;Get Forwarding Address from user
Global $FwdAddr = "FIRST.LASTname@newdomain.com"

; Display a progress bar window.
    ProgressOn("Progress Meter", "DO NOT INTERRUPT PROCESS", "0%", @DesktopWidth - 310, 0)

; Update the progress value of the progress bar window
    ProgressSet("25%", "25%")



; Open Webmail using IE
Global $oIE = _IECreate("http://webmail.sg.yusen-logistics.com")

_IELoadWait($oIE)

;click on Continue
_IELinkClickByText($oIE, "Continue to this website (not recommended).")

;fill in the user and password and click login button
Global $FormUser = _IEGetObjByName($oIE, "user")
Global $FormPassword = _IEGetObjByName($oIE, "password")
Global $Formlogin = _IEGetObjByName($oIE, "login")
_IEFormElementSetValue($FormUser, $EmailAddr)
_IEFormElementSetValue($FormPassword, $Password)
_IEAction($Formlogin, "click")
_IELoadWait($oIE)

; Update the progress value of the progress bar window
    ProgressSet("50%", "50%")

;#### Click on the "Options" link found on the first frame on top of the website ( 0 )
$oFrame = _IEFrameGetCollection ($oIE)
Local $iNumFrames = @extended
;~ Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
;~ Local $oFrame = 0
;~ For $i = 0 To ($iNumFrames - 1)
;~     $oFrame = _IEFrameGetCollection($oIE, $i)
;~     $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
;~ Next
;~ MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)
Sleep(3000)
_IELinkClickByText($oFrame, "Options");click Options link from frame object from its text
_IELoadWait($oIE)



;attach script to new pop up window
$oIE = _IEAttach("https://webmail.sg.yusen-logistics.com/cgi-bin/euadmin.cgi/eup/", "url")
Sleep(6000)


; Update the progress value of the progress bar window
    ProgressSet("65%", "65%")

;### Try using IEFormGetCollection = 1 form, invalid object type
;~ Local $oForms = _IEFormElementGetCollection($oIE)
;~ Local $iNumForms = @extended
;~ MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & $iNumForms & " forms on this page")
;~ Local $oForm
;~ For $i = 0 To $iNumForms - 1
;~     $oForm = _IEFormGetCollection($oIE, $i)
;~     MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name)
;~ Next






;### Try using IEImgGetCollection = 41 blank.gifs found
;~ Local $oImgs = _IEImgGetCollection($oIE)
;~ Local $iNumImg = @extended

;~ Local $sTxt = "There are " & $iNumImg & " images on the page" & @CRLF & @CRLF
;~ For $oImg In $oImgs
;~    $sTxt &= $oImg.src & @CRLF



;~ Next
;~ MsgBox($MB_SYSTEMMODAL, "Img Info", $sTxt)
;~ _IEImgClick($oIE, "https://webmail.sg.yusen-logistics.com/extras/dojo/dojo1.4.3/dojo/resources/blank.gif", "src", 10)



;#### Try using TagNameGetCollection using DIV
;~ Local $oTags_coll = _IETagNameGetCollection($oIE, "DIV")
;~    For $oTag_enum in $oTags_coll
;~    if $oTag_enum.innertext = "Forwarding" then
;~       MsgBox($MB_SYSTEMMODAL, "ID", "ID :" & $oTag_enum.id)


;~            _IEAction($oTag_enum, "click")

;~            ExitLoop

;~        EndIf
;~    Next

;~ ;#### Try using IETableGetCollection = 2 tables, only shows the right hand pane
;~ Local $oTable = _IETableGetCollection($oIE)
;~ Local $iNumTables = @extended
;~ MsgBox($MB_SYSTEMMODAL, "Table Info", "There are " & $iNumTables & " tables on the page")
;~ Local $oTable = _IETableGetCollection($oIE, 1)
;~ Local $aTableData = _IETableWriteToArray($oTable)
;~ _ArrayDisplay($aTableData)


;#### Try using IEPropertyGet then action click
;~ If _IEPropertyGet($oIE, "innertext") Then
;~     MsgBox($MB_SYSTEMMODAL, "Status", "Forwarding link found")
;~   If String(_IEPropertyGet($oIE, "innertext")) = "* Forwarding" Then
;~    _IEAction($oIE, "focus")
;~       _IEAction($oIE, "click")
;~ Else
;~     MsgBox($MB_SYSTEMMODAL, "Status", "Forwarding link not found")

;~ EndIf


;#### Send manual keyboard commands

;~ Send("{TAB 3}")
;~ Send("{DOWN 9}")
;~ Send("{ENTER}")

;#### Get all frames = 0 Frames found
;~ Local $oFrames = _IEFrameGetCollection($oIE)
;~ Local $iNumFrames = @extended
;~ Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
;~ Local $oFrame = 0
;~ For $i = 0 To ($iNumFrames - 1)
;~     $oFrame = _IEFrameGetCollection($oIE, $i)
;~     $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
;~ Next
;~ MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)

;#### Get all tags and IDs in page. Found ID = dijit_TreeNode_10, innertext: *Forwarding)
;~ Local $oElements = _IETagNameAllGetCollection($oIE)
;~ For $oElement In $oElements
;~     If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText)
;~ Next

;#### Click by ID = dijit__TreeNode_10 (double underscore)
;~ Local $oForward = _IEGetObjById($oIE, 'forward')
;~ MsgBox($MB_SYSTEMMODAL, "Status", @error)
;~ _IEAction($oForward, "focus");
;~ _IEAction($oForward, "click");
; Get coordinates and dimensions of the dijit__TreeNode_10
;~ Local $iScreenX = _IEPropertyGet($oForward, "screenx")
;~ Local $iScreenY = _IEPropertyGet($oForward, "screeny")
;~ Local $iBrowserX = _IEPropertyGet($oForward, "browserx")
;~ Local $iBrowserY = _IEPropertyGet($oForward, "browserY")
;~ Local $iWidth = _IEPropertyGet($oForward, "width")
;~ Local $iHeight = _IEPropertyGet($oForward, "height")
;~ Local $iMousespeed = 50
;~ MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed)



;#### Click by text = *Forwarding and * Forwarding (with space)
;~ _IELinkClickByText($oIE, "*Forwarding")

;#### Get all links in page = 0 links found
;~ $oLinks = _IELinkGetCollection($oIE)
;~ Local $iNumLinks = @extended

;~ Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
;~ For $oLink In $oLinks
;~     $sTxt &= $oLink.href & @CRLF
;~ Next
;~ MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)

;#### Click by objectname = forward, * Forward, *Forward
;~ Local $oForward = _IEGetObjByName($oIE, "*Forward")
;~ _IEAction($oForward, "click");click Forward link from frame object from its text

;#### Using IENavigate to the url
;~ _IENavigate($oIE, "https://webmail.sg.yusen-logistics.com/wm/mail/cgi-bin/euadmin.cgi/eup/forward.html")

#cs------------------
;click on Yes radio button and key in forwarding email address
Sleep(1000)
Send("{TAB 4}")
Send("{SPACE}")
Send("{TAB}")
Send($FwdAddr)
Send("+{TAB 3}")
Send("{SPACE}")
Sleep(1500)
Send("{TAB 2}")
Send("{ENTER}")
#ce------------------
;~ ;Click on the "Apply Button"
;~ $oFrame = _IEFrameGetCollection ($oIE, 1)
;~ _IEImgClick($oFrame, "Apply", "alt")
;~ Sleep(2000)
;~ ;Click on Close
;~ ;_IEImgClick($oFrame, "Close", "alt")
;~ _IEQuit($oIE)
$oIE = _IEAttach("WebMail - Corporate Edition")
;~ _IEQuit($oIE)

 

Options_Page.png

Share this post


Link to post
Share on other sites
bikerbrooks
; example of tag and innerhtml <span class="buttonText">start</span>
    $spans = $ie.document.getElementsByTagName('span')
    for $s in $spans
    If $s.innerHTML = "start" Then
        $s.click()
    EndIf
    Next

if to right click view sourcecode on the page find the tag and the innerHTML this will work

i use w3schools for this as they give you examples

Share this post


Link to post
Share on other sites
mLipok

How many "!DOCTYPE" tag you see in your HTML source in your webpage ?

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
dnnytn
On 1/6/2016 at 4:16 AM, mLipok said:

How many "!DOCTYPE" tag you see in your HTML source in your webpage ?

 

hi mLipok, i only see 1 x <!Doctype> tag when i use the View Source function in IE. 

Share this post


Link to post
Share on other sites
dnnytn
On 1/4/2016 at 2:41 AM, bikerbrooks said:
; example of tag and innerhtml <span class="buttonText">start</span>
    $spans = $ie.document.getElementsByTagName('span')
    for $s in $spans
    If $s.innerHTML = "start" Then
        $s.click()
    EndIf
    Next

if to right click view sourcecode on the page find the tag and the innerHTML this will work

i use w3schools for this as they give you examples

hi bikerbrooks, based on the View Source page, i am not able to get any clues on which Tag. 

options_items.push({
    'id'    :   'forward',
    'label' :   localevar.get('Forwarding'), 
    'url'   :   '/cgi-bin/euadmin.cgi/eup/forward.html',
    'pName' :   'mail'
});

 

Share this post


Link to post
Share on other sites
mLipok
On 4.01.2016 at 9:11 AM, dnnytn said:

3a. On the pop-up box,  (???? What a PopUp ??? )
3b. click on "Mail",
3c. then "Forwarding"

......

I am stuck on step 3.  Please be more precisely: What you mean: 3a ? 3b ? 3c ?

btw.
Inpsect "Mail" and give here Outer HTML snippet for this part of "Tree" .


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • MakzNovice
      By MakzNovice
      Hello Experts,
      I am working on modifying table data of a browser currently in IE (soon in FF)
      My sequence of operations:
      1. Activate Browser
      2. Get Browser table
      3. Modify data  in table
      4. Suppress any warning/error message from webpage
      5. Activate the Webpage again 
      6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5})
       
      My problem is at Step 5, as it activates the wrong window ( last used application rather than my browser window)
      My code snippet for it as follows
      $bFoundWindow = False Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]") Local $hWND = 0 For $i = 1 To $aList[0][0] If False = $bFoundWindow And $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 1) Then WinActivate($aList[$i][1]) ; 1. Activate Browser window WinSetState ( $aList[$i][1], "", @SW_MAXIMIZE) $hWND = $aList[$i][1] $objEditIE = _IEAttach ($aList[$i][1], "hwnd") $oTitles = _IETagNameGetCollection($objEditIE, "TITLE") For $oTitle In $oTitles $sTitle = $oTitle.innerText If $sTitle = $searchString Then MsgBox(0,"APPLICATION Found", "Got Edit List Window", 1) $bFoundWindow = True ExitLoop EndIf Next EndIf Next If False = $bFoundWindow Then MsgBox(0,"Error","Please launch Edit window for updating values in Browser prior to script execution",10) Exit EndIf ; MY CODE HERE TO MODIFY TABLE ; 2. Get Browser table ; 3. Modify data  in table ; Check if message from webpage pop-up window exists if so click ok on it Local $nCounter = 0 Local $nMaxCounter = 5 while 1 If WinExists("Message from webpage","") Then ControlClick("Message from webpage","","Button1","primary",1) ;4. Suppress any warning/error message from webpage Else $nCounter = $nCounter + 1 Sleep(100) ;MsgBox(0,"Counter", $nCounter, 1) If $nCounter = $nMaxCounter Then ExitLoop EndIf WEnd ;5. Activate the Webpage again  WinActivate($hWND) ; have already tried WinActivate($aList[$i][1]) but no success ;6. Send {F11} key sequence twice to achieve some update without Updating form ( {F5}) Send("{F11}") WinActivate($hWND) ;WinActivate($aList[$i][1]) Sleep(100) Send("{F11}") Any support will be highly appreciated
    • MakzNovice
      By MakzNovice
      Hello Experts,
      I am working on custom application details of which I am unable to share.
      But here is statement of my problem, I have two IE windows one window with Title "Parent " and other with "TableEdit", but for some reason when I get WinList they are shown as 2 processes each. ( see attached image)
      Since my most important motive is to modify table data in 'TableEdit' I try to access the table in it
      My code snippet is 
      ***********************************************************************************************
      $searchString = "TableEdit"
      Local $aList = WinList("[REGEXPTITLE:(?i)(.*Internet Explorer.*)]")
      _ArrayDisplay($aList)
      For $i = 1 To $aList[0][0]
          If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
              ;MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
              If 0 <> StringInStr($aList[$i][0],"TableEdit") Then
                  $objEditIE = _IEAttach ($aList[$i][1])
                  ExitLoop
              EndIf
          EndIf
      Next
      WinActivate($objEditIE)
      $oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
      $iNumFrames = @extended
      MsgBox(0,"Got pagecontent",@error) ; returns 3, indicating invalid data type
      MsgBox(0,"Number of Frame",$iNumFrames) ; returns 1, expected value is 1 
      ***********************************************************************************************
      and If I do code as below the return value is different
      $searchString = "TableEdit"
       $objEditIE = _IEAttach ($searchString, "title")
      WinActivate($objEditIE)
      $oPageContentListFrame = _IEFrameGetObjByName($objEditIE, "iframe_1")
      $iNumFrames = @extended
      MsgBox(0,"Got pagecontent",@error) ; returns 0
      MsgBox(0,"Number of Frame",$iNumFrames) ; returns 0. expected value is 1
      ***********************************************************************************************
      What is wrong with my code? 
      Why do I see two process each for IE for each window?
       
      WinListImage.bmp
    • guinness
      By guinness
      Just trying out the latest version of AutoIt and thinking more functional
      #include <Array.au3> ; Example ; An example of filtering, mapping and reducing arrays, using a function reference. ; This is similiar to how it would be done in the likes of JavaScript ; i.e. more functional (declarative) than procedural (imperative) ; Filter example Local $aiFilteredBefore[] = [1, 2, 3, 50, 30, 40, 20, 30] Local $aiFilteredAfter = _ArrayFilter($aiFilteredBefore, GtrThan30) _ArrayDisplay($aiFilteredAfter, '_ArrayFilter::') ; Map example Local $aiMappedBefore[] = [1, 2, 3, 4, 5, 6, 7, 8, 9] Local $aiMappedAfter = _ArrayMap($aiMappedBefore, MultiplyByTwo) _ArrayDisplay($aiMappedAfter, '_ArrayMap::') ; Reduce example ; Sum all values in the array Local $aiReducedBefore[] = [1, 2, 3, 50, 30, 40, 20, 30] ConsoleWrite('_ArrayReduce:: ' & _ArrayReduce($aiReducedBefore, SumValues) & @CRLF) ; Passing an empty array, will return the initial value; otherwise, sets @error to 4 ; if no initial value is defined Local $aEmpty[] = [] ConsoleWrite('_ArrayReduce:: ' & _ArrayReduce($aEmpty, SumValues, 0) & @CRLF) ; Array callback functions (for the examples only) Func GtrThan30($iValue) Return $iValue > 30 EndFunc ;==>GtrThan30 Func MultiplyByTwo($iValue, $iIndex, $aiArray) ; Notice how the function is called with the optional arguments "index" and "original array" ConsoleWrite('Index:: ' & $iIndex & ', Array:: ' & _ArrayToString($aiArray) & @CRLF) Return $iValue * 2 EndFunc ;==>MultiplyByTwo Func SumValues($a, $b) Return $a + $b EndFunc ;==>SumValues ; Functions ; The callback function is invoked with fn(value, [index, [array]]) Func _ArrayFilter($avArray, $hFunc) If Not IsArray($avArray) Then ; Null is more appropriate than returning the likes of -1 or an empty array Return SetError(1, 0, Null) EndIf If Not IsFunc($hFunc) Then Return SetError(2, 0, Null) EndIf Local Const $iLength = UBound($avArray) Local $avFiltered[$iLength] If $iLength = 0 Then Return $avFiltered EndIf Local $iIndex = 0 For $i = 0 To $iLength - 1 Local $bIsFiltered = __ArrayCall($hFunc, 3, $avArray[$i], $i, $avArray) If @error Then Return SetError(@error, @extended, Null) ElseIf $bIsFiltered Then $avFiltered[$iIndex] = $avArray[$i] $iIndex += 1 EndIf Next ReDim $avFiltered[$iIndex] Return $avFiltered EndFunc ;==>_ArrayFilter ; The callback function is invoked with fn(value, [index, [array]]) Func _ArrayMap($avArray, $hFunc) If Not IsArray($avArray) Then ; Null is more appropriate than returning the likes of -1 or an empty array Return SetError(1, 0, Null) EndIf If Not IsFunc($hFunc) Then Return SetError(2, 0, Null) EndIf Local Const $iLength = UBound($avArray) Local $avMapped[$iLength] If $iLength = 0 Then Return $avMapped EndIf For $i = 0 To $iLength - 1 $avMapped[$i] = __ArrayCall($hFunc, 3, $avArray[$i], $i, $avArray) If @error Then Return SetError(@error, @extended, Null) EndIf Next Return $avMapped EndFunc ;==>_ArrayMap ; The callback function is invoked with fn(current, value, [index, [array]]) Func _ArrayReduce($avArray, $hFunc, $vInitial = Default) If Not IsArray($avArray) Then ; Null is more appropriate than returning the likes of -1 or an empty array Return SetError(1, 0, Null) EndIf If Not IsFunc($hFunc) Then Return SetError(2, 0, Null) EndIf Local $bHasInitial = @NumParams >= 3 Local $iLength = UBound($avArray) If $iLength = 0 Then If Not $bHasInitial Then Return SetError(4, 0, Null) EndIf Return $vInitial EndIf For $i = 0 To $iLength - 1 If $bHasInitial Then $vInitial = __ArrayCall($hFunc, 3, $vInitial, $avArray[$i], $i, $avArray) If @error Then Return SetError(@error, @extended, Null) EndIf Else $bHasInitial = True $vInitial = $avArray[$i] EndIf Next Return $vInitial EndFunc ;==>_ArrayReduce Func __ArrayCall($hFunc, $iError, $vArg1 = Default, $vArg2 = Default, $vArg3 = Default, $vArg4 = Default) Local Const $CALL_ERROR = 0xDEAD Local Const $CALL_EXTENDED = 0xBEEF Local $vRet = Call($hFunc, $vArg1) If @error = $CALL_ERROR And @extended = $CALL_EXTENDED Then $vRet = Call($hFunc, $vArg1, $vArg2) If @error = $CALL_ERROR And @extended = $CALL_EXTENDED Then $vRet = Call($hFunc, $vArg1, $vArg2, $vArg3) If @error = $CALL_ERROR And @extended = $CALL_EXTENDED Then $vRet = Call($hFunc, $vArg1, $vArg2, $vArg3, $vArg4) If @error = $CALL_ERROR And @extended = $CALL_EXTENDED Then ; The function exists, but there is no appropriate function signature Return SetError($iError, 0, Null) EndIf EndIf EndIf EndIf Return SetError(@error, @extended, $vRet) EndFunc ;==>__ArrayCall  
    • Chimp
      By Chimp
      An example on how to inject jQuery into a web page
      It can be useful to manage the page from AutoIt using jQuery.
      Idea from here: http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet
      Suggestions and improvements are welcome
      #include <ie.au3> Example() Func Example() Local $oIE = _IECreate("www.google.com") Local $jQuery = _jQuerify($oIE) MsgBox(0, "Version", "jQuery version: " & $jQuery.fn.jquery) MsgBox(0, "Example", "click ok to exit." & @CRLF & "Google logo will fade out by jQuery...") $jQuery('#hplogo').fadeOut(3000) ; jQuery will fade out the google logo EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _jQuerify ; Description ...: ; Syntax ........: _jQuerify(Byref $oIE) ; Parameters ....: $oIE - Object variable of an InternetExplorer.Application. ; Return values .: an object variable pointing to the jQuery library ; Author ........: Chimp ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _jQuerify(ByRef $oIE) Local $jsEval, $jQuery, $otherlib = False ; create a reference to the javascript eval() function $oIE.document.parentWindow.setTimeout('document.head.eval = eval', 0) Do Sleep(250) $jsEval = Execute('$oIE.Document.head.eval') Until IsObj($jsEval) ; if jQuery is not already loaded then load it If $jsEval("typeof jQuery=='undefined'") Then ; check if the '$' (dollar) name is already in use by other library If $jsEval("typeof $=='function'") Then $otherlib = True Local $oScript = $oIE.document.createElement('script'); $oScript.type = 'text/javascript' ; If you want to load jQuery from a disk file use the following statement ; where i.e. jquery-1.9.1.js is the file containing the jQuery source ; (or also use a string variable containing the whole jQuery listing) ;~ $oScript.TextContent = FileRead(@ScriptDir & "\jquery-1.9.1.js") ; <--- from a file ; If you want to download jQuery from the web use this statement $oScript.src = 'https://code.jquery.com/jquery-latest.min.js' ; <--- from an url $oIE.document.getElementsByTagName('head').item(0).appendChild($oScript) Do Sleep(250) Until $jsEval("typeof jQuery == 'function'") EndIf Do Sleep(250) $jQuery = $jsEval("jQuery") Until IsObj($jQuery) If $otherlib Then $jsEval('jQuery.noConflict();') Return $jQuery EndFunc ;==>_jQuerify  
    • Tippex
      By Tippex
      I have a problem trying to use _IEAttach to recover control after a Windows Explorer reset (e.g. on Windows 7), since all the 
      InternetExplorer.Application objects appear to be destroyed by this event. An example of this is when a PC has some kind of fault causing a pop-up error message "Windows Explorer has stopped working". I can simulate this event by using Windows Task Manager to end the Explorer.exe process then to file, new task (run...) Explorer.exe
      After this event, _IEAttach gives an @error of: 
      7 ($_IEStatus_NoMatch) - No Match
      However, using WinList() followed by WinGetText() I can recover the URL for an IE session that has lost its 
      InternetExplorer.Application object which could be used to _IECreate a new session (the $iTryAttach fails) and WinKill() the original session but the result is a if a refresh had been done (any form entries are lost) . Unfortunately form entries do not appear as text or hidden text to Windows so I'm looking for the best way to read the contents of an Internet Explorer screen (even if just text without structure). 
      When there is no InternetExplorer.Application object (because of some Windows fault) but still with an Internet Explorer session running, I tried to read its contents by a "Select All" & "Copy to Clipboard" but its form entries are blanked and combo boxes choices are all displayed with no way of finding out which ones were selected.
      Local $ClipBoardSave = _ClipBoard_GetData() ;not ClipGet() which is text only ClipPut("") ;Clear User's Clipboard Local $sText = "" Local $hWnd = WinActivate("Window Title", "") If IsHWnd($hWnd) Then Local $bStatusCtrlSend = ControlSend("Window Title", "", "", "^a^c") If $bStatusCtrlSend Then Local $bStatusCtrlClick = ControlClick("Window Title", "", "") If $bStatusCtrlClick Then $sText = ClipGet() _ClipBoard_SetData($ClipBoardSave) ;not ClipPut($ClipBoardSave) which is text only  
      Is  there a solution to this please?
×