Jump to content

Click an IE javascript slide-out button - how?


Recommended Posts

I have a website using a "RadToolBar_Office2007" javascript slde-out which has resisted all attempts to be activated or clicked.

First off, IE seems to be unable to find it as an object:

; click the menu button
    $oStats = _IEFormElementGetObjByName($oIE, "aspnetForm")
    $oButton = _IEGetObjByName($oStats, "rmExpandDown")
    If IsObj($oButton) Then
        MsgBox(0,"OK", "It's an object");
    Else
        MsgBox(0,"Nope","It's not an object");
    EndIf

It does not detect it as an object.

MODIv2 shows the following about the button:

attributes

  • class : rmText rmExpandDown
dimensions

  • Width : 43px
  • Height : 24px
  • Top : 87px
  • Left : 22px
parent structure

  • html
  • body
  • form id="aspnetForm"
  • div id="pageHeader" class="fixed_menu"
  • div id="pageHeaderIndent"
  • div id="ctl00_Header1_toolbarCommands" class="RadToolBar RadToolBar_Horizontal RadToolBar_Office2007 RadToolBar_Office2007_Horizontal"
  • div class="rtbOuter"
  • div class="rtbMiddle"
  • div class="rtbInner"
  • ul class="rtbUL"
  • li class="rtbItem rtbTemplate rtbItemHovered "
  • div id="ctl00_Header1_toolbarCommands_i0_menuNavigation" class="RadMenu RadMenu_Web20"
  • ul class="rmHorizontal rmRootGroup"
  • li class="rmItem rmFirst rmLast"
  • a class="rmLink"
children

  • #text
Here are the items in the javascript form from the page source:

<div id="ctl00_Header1_toolbarCommands" class="RadToolBar RadToolBar_Horizontal RadToolBar_Office2007 RadToolBar_Office2007_Horizontal" style="font-size:Larger;width:980px;z-index:9000;">
<!-- 2009.3.1314.35 --><div class="rtbOuter">
  <div class="rtbMiddle">
   <div class="rtbInner">
    <ul class="rtbUL">
     <li class="rtbItem rtbTemplate">
                    <div id="ctl00_Header1_toolbarCommands_i0_menuNavigation" class="RadMenu RadMenu_Web20">
      <ul class="rmHorizontal rmRootGroup">
       <li class="rmItem rmFirst rmLast"><a href="javascript:void(0);" class="rmLink"><span class="rmText">Menu</span></a><div class="rmSlide">
        <ul class="rmVertical rmGroup rmLevel1">
         <li class="rmItem rmFirst"><a href="javascript:void(0);" class="rmLink"><span class="rmText">Process Media</span></a><div class="rmSlide">
          <ul class="rmVertical rmGroup rmLevel2">
           <li class="rmItem rmFirst"><a href="#" class="rmLink"><span class="rmText">Container Pickup</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Download Inventory</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">OM Distribution List</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Scan Verification</span></a></li><li class="rmItem rmLast"><a href="#" class="rmLink"><span class="rmText">Send List File</span></a></li>
          </ul>
         </div></li><li class="rmItem "><a href="javascript:void(0);" class="rmLink"><span class="rmText">Authorization</span></a><div class="rmSlide">
          <ul class="rmVertical rmGroup rmLevel2">
           <li class="rmItem rmFirst"><a href="#" class="rmLink"><span class="rmText">Search Users</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Comments</span></a></li><li class="rmItem rmLast"><a href="#" class="rmLink"><span class="rmText">Account Status</span></a></li>
          </ul>
         </div></li><li class="rmItem "><a href="javascript:void(0);" class="rmLink"><span class="rmText">Request</span></a><div class="rmSlide">
          <ul class="rmVertical rmGroup rmLevel2">
           <li class="rmItem rmFirst"><a href="#" class="rmLink"><span class="rmText">Search Requests</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Search Media Destruction Requests</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Deliver Media</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">New Container/Lock/Insert</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">New or Empty Transport</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Other</span></a></li><li class="rmItem rmLast"><a href="#" class="rmLink"><span class="rmText">Reschedule Service</span></a></li>
          </ul>
         </div></li><li class="rmItem "><a href="javascript:void(0);" class="rmLink"><span class="rmText">Research</span></a><div class="rmSlide">
          <ul class="rmVertical rmGroup rmLevel2">
           <li class="rmItem rmFirst"><a href="#" class="rmLink"><span class="rmText">Completed Library Audits</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Corrective Action Request</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Search Containers</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Search Open Media</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Vault Status Reports</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Global Media Locator</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">OM Vault Status Summary</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Scan Verification History</span></a></li><li class="rmItem rmLast"><a href="#" class="rmLink"><span class="rmText">Inbound/Outbound Report</span></a></li>
          </ul>
         </div></li><li class="rmItem "><a href="javascript:void(0);" class="rmLink"><span class="rmText">Disaster Recovery</span></a><div class="rmSlide">
          <ul class="rmVertical rmGroup rmLevel2">
           <li class="rmItem rmFirst rmLast"><a href="#" class="rmLink"><span class="rmText">Search Employees</span></a></li>
          </ul>
         </div></li><li class="rmItem "><a href="javascript:void(0);" class="rmLink"><span class="rmText">Admin</span></a><div class="rmSlide">
          <ul class="rmVertical rmGroup rmLevel2">
           <li class="rmItem rmFirst"><a href="#" class="rmLink"><span class="rmText">Edit My Info</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Edit My Preferences</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Customer Preferences</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Change Password</span></a></li><li class="rmItem "><a href="#" class="rmLink"><span class="rmText">Add Retention Profiles</span></a></li><li class="rmItem rmLast"><a href="#" class="rmLink"><span class="rmText">Retention Profiles</span></a></li>
          </ul>
         </div></li><li class="rmItem rmLast"><a href="#" class="rmLink"><span class="rmText">Home</span></a></li>
        </ul>
       </div></li>
      </ul><input id="ctl00_Header1_toolbarCommands_i0_menuNavigation_ClientState" name="ctl00_Header1_toolbarCommands_i0_menuNavigation_ClientState" type="hidden" />
     </div>
                </li>
    </ul>
   </div>
  </div>
</div><input id="ctl00_Header1_toolbarCommands_ClientState" name="ctl00_Header1_toolbarCommands_ClientState" type="hidden" />
</div>
    <br />

It's not really a form and not really a button, so how do you deal with these? I got by for a while with a dumb mouse move and sending tabs, arrows and spacebar, but the mouse move is susceptible to many factors and it's not reliable.

Thanks!

Link to comment
Share on other sites

Hi,

You can loop over all elements and match the class to get the element you need, here is an example...

#include <IE.au3>


$sURL = ...url...

$oIE = _IECreate($sURL, 1, 1) ; create IE window, go to URL

$oElems = _IETagNameGetCollection($oIE, "li") ; get all li tags
For $oElem In $oElems ; loop over all elements
    If StringInStr($oElem.className, "rmFirst rmLast") Then ; this is the tag we need
        $oLink = _IETagNameGetCollection($oIE, "a", 0) ; get the first link inside the element
        _IEAction($oLink, "click") ; click the link
        ExitLoop
    EndIf
Next
Link to comment
Share on other sites

Thanks for the code. How would I get $oLink properties so I can see what link it is instead of clicking it?

I think the difficulty is it's not a real form. Elsewhere on the site in question I was able to parse out a dropdown into an array and then use it to submit into a form:

; get the form object and parse out the info
$oCustForm = _IEGetObjByName ($oIE, "selCustomerAccount")
$sCustList = _IEPropertyGet ($oCustForm, "innerhtml")
$aCustList = StringRegExp ($sCustList, '>d+[ws-,()]+<', 3)
For $sTheCust In $aCustList
    If $runOnce = 1 Then
        $oCustForm = _IEGetObjById ($oIE, "ucHeader_selUserAccount")
        _IEFormElementOptionSelect ($oCustForm, $sTheCust, 1, "byText")
    EndIf
    $reportResult = getReport($sTheCust)
    ; $reportResult = getReport($aCustList[14])
    $runOnce = 1
Next

I don't think that's going to work here.

Link to comment
Share on other sites

Here's the best I could come up with. It works. I don't like MouseMove, but this will account for the user changing the layout of toolbars and such.

; ok I give up - let's find the logo gif and base the mouse position off that
$oImgs = _IEImgGetCollection($oIE)
$iNumImg = @extended
;MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page")
For $oImg In $oImgs
  If $oImg.nameProp = "headerApplicationLogo.gif" Then
   $iULx = _IEPropertyGet($oImg, "screenx")
   $iULy = _IEPropertyGet($oImg, "screeny")
;~    MsgBox(0, "Img Info", "src=" & $oImg.src & @CR & _
;~           "FileName: " & $oImg.nameProp & @CR & _
;~           "x-coordinate of the top left corner: " & $iULx & @CR & _
;~           "y-coordinate of the top left corner: " & $iULy & @CR & _
;~           "Width: " & $oImg.width & @CR & _
;~           "Height: " & $oImg.height & @CR & _
;~           "Border: " & $oImg.border)
  EndIf
Next
If WinExists("SecureSync - Windows Internet Explorer","https://www3.securesync.com/m/HomePagePersonnel.aspx") Then
  WinActivate("SecureSync - Windows Internet Explorer","https://www3.securesync.com/m/HomePagePersonnel.aspx")
  MouseMove($iULx + 31, $iULy + 86)
  MouseClick("left", $iULx + 31, $iULy + 86, 1)
EndIf
Link to comment
Share on other sites

Here is an example of navigating that menu control on another site without using MouseClick. Note that there is noting wrong with ModIV2, but it hasn't been updated in over 6 years. Other options, like DebugBar, may be useful to you.

#include <IE.au3>
$oIE = _IECreate("[url="http://demos.telerik.com/aspnet-ajax/toolbar/examples/applicationscenarios/gridcommanditem/defaultcs.aspx?product=toolbar"]http://demos.telerik.com/aspnet-ajax/toolbar/examples/applicationscenarios/gridcommanditem/defaultcs.aspx?product=toolbar[/url]")

; Expand fly-down menu with mouseover
$oMenu = _IEGetObjById($oIE, "Header1_Menu1_RadMenu1")
$oItem1 = _IETagnameGetCollection($oMenu, "li", 0)
$oItem1.fireEvent("onMouseOver")
Sleep(2000)

; drill down to specific menu item and click the anchor link
$oDiv1 = _IETagnameGetCollection($oItem1, "div", 0)
$oDiv2 = _IETagnameGetCollection($oDiv1, "div", 0)
$oDiv3 = _IETagnameGetCollection($oDiv2, "div", 0)
$oDiv4 = _IETagnameGetCollection($oDiv3, "div", 0)
$oA = _IETagnameGetCollection($oDiv3, "a", 0)
_IEAction($oA, "click")

Dale

Edit: remove extraneous line from example and add comments

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...