Jump to content

$elem.fireEvent("onmouseover") javascript not working.


Fehera
 Share

Recommended Posts

Hi all, 

I've started using autoit couple of months ago and seems like I can get all info when I stuck and I was able to work around all problems. However, I now stuck on a table cell element that seems like requires the psychical mouse over it. 

I've tried mouseover, onmouseover, _IEAction($elem, "click"), _IEAction($elem, "focus") Send("{ENTER}") .... etc

I've also torn apart the html to see what actual events firing and in Chrome I can see it is the onmouseover event. 

I always use IE11 when running the bot, but I prefer to see the source of the html and event monitoring in Chrome. It is better I think. 

The onmouseover fires when I move my mouse over the "F: FRESH FOODS" table cell. 

<td rowspan="1" colspan="1" class="r-c8_K59 hl xtab-td " ei="21" style="" r="1" title=""><span>F : FRESH FOODS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></td>

I can find this element by using the below

#include <IE.au3>

$hWnd = WinGetHandle("Sales and Stock Daily. MicroStrategy - Internet Explorer")
$oIE = _IEAttach($hWnd, "hwnd")

$oElems = _IETagNameGetCollection($oIE, "td")
$oElemsCount = @extended
ConsoleWrite("Elements count: " & $oElemsCount & @LF)

For $oElem In $oElems
    ConsoleWrite("  INNERTEXT: " & $oElem.innerText & @LF)

    If StringInStr($oElem.innerText, "F : FRESH FOODS") > 0 Then
        ConsoleWrite("FRESH FOODS TD element found" &  @LF)
        $oElem.fireEvent("onmouseover")     
    EndIf 
Next

Here is the output of the above snip

Starting file test.au3...

Elements count: 105
    INNERTEXT: Excel Export Bar - Please click on the drop down on the right side of this Bar to export this grid to excel
DateSystem DateMeasure Type Code For Day And WTDTesco Org. UnitProduct DivisionSales Value TYSales % Var LWLFL % TYSales Volume TYSales % Var LW (Vol)Waste % TYStock Volume TYDays Cover TY (Vol)Days Cover Var LW (Vol)Supplier to DC Gross SL % TYDC to Store SL % TYCSL % TY (Vol)
18/02/201918/02/2019DAYBRASHER R.F : FRESH FOODS             120,0251.27%7.83%68,153(1.60%)2.05%504,4747.60.2NANANA
Total 120,0251.27%7.83%68,153(1.60%)2.05%504,4747.60.2NANANA
FRESH FOODS TD element found
    INNERTEXT: Date
    INNERTEXT: System Date
    INNERTEXT: Measure Type Code For Day And WTD
    INNERTEXT: Tesco Org. Unit
    INNERTEXT: Product Division
    INNERTEXT: Sales Value TY
    INNERTEXT: Sales % Var LW
    INNERTEXT: LFL % TY
    INNERTEXT: Sales Volume TY
    INNERTEXT: Sales % Var LW (Vol)
    INNERTEXT: Waste % TY
    INNERTEXT: Stock Volume TY
    INNERTEXT: Days Cover TY (Vol)
    INNERTEXT: Days Cover Var LW (Vol)
    INNERTEXT: Supplier to DC Gross SL % TY
    INNERTEXT: DC to Store SL % TY
    INNERTEXT: CSL % TY (Vol)
    INNERTEXT: 18/02/2019
    INNERTEXT: 18/02/2019
    INNERTEXT: DAY
    INNERTEXT: BRASHER R.
    INNERTEXT: F : FRESH FOODS             
FRESH FOODS TD element found

test.au3 -> Exit Code: 0    (Runtime: 1.82 sec)

Please see the attached images for TD cell without hover, TD cell with hover, TD cell hover on arrow

When I move the mouse over the TD the TD's background turns lightblue and a little arrow element appears on the right. 

This arrow element doesn't exists on page load. It is only generated on mouseover. Seems like the div's ID is "mstr107" once it created. I believe it is always mstr107. Cleared my cache and it stays mstr107.

This is the arrow's html 

<div id="mstr107" class="mstrmojo-Popup mstrXtabCellHoverPopup" style="display: none; left: 768px; top: 14px;">
   <div class="mstrmojo-Popup-shadow mstrmojo-popup-shadow"></div>
   <div class="mstrmojo-Popup-title mstrmojo-popup-title"></div>
   <div class="mstrmojo-Popup-content mstrmojo-popup-content">
      <div id="mstr108" class="mstrmojo-Button" title="" style="display: block;" 
            ontouchstart="mstrmojo.dom.captureDomEvent('mstr108','touchstart', self, event)" 
            onclick="mstrmojo.dom.captureDomEvent('mstr108','click', self, event)" 
            onmousedown="mstrmojo.dom.captureDomEvent('mstr108','mousedown', self, event)" 
            onmouseup="mstrmojo.dom.captureDomEvent('mstr108','mouseup', self, event)">
         <div class="mstrmojo-Button-text ">&nbsp;</div>
      </div>
   </div>
</div>

 

While I typing up my question I had the idea to inject the mstr107's code and trigger it, but 1.) I don't know how to inject html using autoit, 2.) I would prefer use no injection if possible.

I apologies if the above is too much to digest, but I wanted to give you as much info as possible. Due to I'm unable to give you credentials to this website I had to post the html code here. 

I look forward to your kind help. 

Many Thanks

A. 

onmouseover event.PNG

TD hover on the arrow.PNG

TD with hover.PNG

TD without hover.PNG

Link to comment
Share on other sites

Just in case someone could help, here are an update. 

When I find the TD, the $oElem.fireEvent("onmouseover") actually triggers the javascript to create that mstr107 element. 

I'm still stuck on the how to click on it as I tried all combination using the normal and _IEActions. 

$elem.setAttribute("style", "display:block")
$elem.fireEvent("ontouchstart")
$elem.fireEvent("onclick")
$elem.fireEvent("onmousedown")
$elem.fireEvent("onmouseup")

The "display:block" not showing that element. Tried to change the color:red and it adds that color attribute, sot definitely has access to that element. 

 

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...