Jump to content

IE Problem with Button Click


Recommended Posts

I am running on Windows 7, Internet Explorer 8 and have been struggling to use IEAction "click" on one of the buttons with my html. I have been following another recent post on a similar problem but think that the two problems might be different. I have tried both the beta version of AutoIt and the latest release and neither seem to work. Here is the HTML...

<table cellspacing=0>

<tr>

<td class="ResultLinksCell"><a name="ReportLinkMenu" class="ARABTitle" href="javascript:void(null)" onclick="return NQWPopupMenu(event,'idDownloadLinksMenud:dashboard~p:187d0kpkgsfvqipr~r:jd4pn5gojvgu3ots')">

Download

</a>

<div id="idDownloadLinksMenud:dashboard~p:187d0kpkgsfvqipr~r:jd4pn5gojvgu3ots" class="NQWMenu" onmouseover="NQWMenuMouseOver(event)">

<table cellspacing="0px" class="menuShadowWrapper" >

]<tr><td rowspan="2" colspan="2" class="shadowMenuCell">

<a class="NQWMenuItem" name="SectionElements" href="javascript:void(null);" onclick="NQWClearActiveMenu();Download('saw.dll?Go&amp;_scid=9O9-su0C2Zo&amp;ViewID=d\x253adashboard\x257ep\x253a187d0kpkgsfvqipr\x257er\x253ajd4pn5gojvgu3ots&amp;Action=Download&amp;SearchID=r55l94pr6rcb23b8cic9o8673q&amp;PortalPath=/shared/Xirf\x2520Basic/_portal/Amazon\x2520Retail\x2520Analytics\x2520Basic&amp;Page=Sales\x2520\x2526\x2520Inv\x2520-\x2520Item\x2520Detail\x2520(Sourcing)&amp;ViewState=d734cralesu5slb910vmo59qg2&amp;ItemName=SalesInvItemDetailSourcingVendorview&Format=txt&Extension=.csv'); return false">

Download Data (Recommended)

</a>

<a class="NQWMenuItem" name="SectionElements" href="javascript:void(null);" onclick="NQWClearActiveMenu();Download('saw.dll?Go&amp;_scid=9O9-su0C2Zo&amp;ViewID=d\x253adashboard\x257ep\x253a187d0kpkgsfvqipr\x257er\x253ajd4pn5gojvgu3ots&amp;Action=Download&amp;SearchID=r55l94pr6rcb23b8cic9o8673q&amp;PortalPath=/shared/Xirf\x2520Basic/_portal/Amazon\x2520Retail\x2520Analytics\x2520Basic&amp;Page=Sales\x2520\x2526\x2520Inv\x2520-\x2520Item\x2520Detail\x2520(Sourcing)&amp;ViewState=d734cralesu5slb910vmo59qg2&amp;ItemName=SalesInvItemDetailSourcingVendorview&Format=excel&Extension=.xls'); return false">

Download to Excel

</a>

<a class="NQWMenuItem"" name="SectionElements" href="javascript:void(null);" onclick="NQWClearActiveMenu();Download('saw.dll?Go&amp;_scid=9O9-su0C2Zo&amp;ViewID=d\x253adashboard\x257ep\x253a187d0kpkgsfvqipr\x257er\x253ajd4pn5gojvgu3ots&amp;Action=Download&amp;SearchID=r55l94pr6rcb23b8cic9o8673q&amp;PortalPath=/shared/Xirf\x2520Basic/_portal/Amazon\x2520Retail\x2520Analytics\x2520Basic&amp;Page=Sales\x2520\x2526\x2520Inv\x2520-\x2520Item\x2520Detail\x2520(Sourcing)&amp;ViewState=d734cralesu5slb910vmo59qg2&amp;ItemName=SalesInvItemDetailSourcingVendorview&Format=powerpoint'); return false">

.....

My program First clicks on the Download button (successfully), At this point, I can then click on a list of items, one being Download to Excel. When I try to click on this using IEAction, I see a window flash up and then it disappears. When I do a manual mouse click on it using MouseClick and the position on the screen, a Download pop-up is displayed. Here is the code that works...

$oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")

If @error <> 0 Then

FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)

Else

_IEAction($oElementy,"focus")

_IEAction($oElementy,"click")

FileWriteLine($logfile, "Click on Download Button. _IEAction = " & @Error)

MouseClick( "Left",68,733)

...

After this the Download pop up is displayed

Here is what I have tried using IE:

; Click on Download button

$oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")

If @error <> 0 Then

FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)

Else

_IEAction($oElementy,"focus")

_IEAction($oElementy,"click")

$oExcelDownload = _IEGetObjByName($oIEb,"SectionElements",11)

MsgBox(0,"","ExcelDownload GetObj error = " & @Error)

MouseMove(68,733)

_IEAction($oExcelDownload,"focus")

_IEAction($oExcelDownload,"click")

MsgBox(0,"","Click Error = " & @Error)

After this, it looks like the download pop up tries to display, but then disappears. All errors displayed, are zero. I have also verified that the "SectionElements" object is the correct one to click on.

After reading an earlier post, I also tried:

; Click on Download button

$oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")

If @error <> 0 Then

FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)

Else

_IEAction($oElementy,"focus")

_IEAction($oElementy,"click")

$oExcelDownload = _IEGetObjByName($oIEb,"SectionElements",11)

MsgBox(0,"","ExcelDownload GetObj error = " & @Error)

$oExcelDownload.fireEvent("onmousedown")

$oExcelDownload.fireEvent("onmouseup")

_IEAction($oExcelDownload, "click")

It seems the earlier post was able to get the above code working but this doesn't seem to work for me with either version of AutoIt. Please let me know if there is any additional information that I can provide to make this easier to debug. Any help would be appreciated.

Link to comment
Share on other sites

Struggling not only with my coding in autoit but posting properly. Here is my original post with autoit tags. Hopefully this makes it easier to read.

I am running on Windows 7, Internet Explorer 8 and have been struggling to use IEAction "click" on one of the buttons with my html. I have been following another recent post on a similar problem but think that the two problems might be different. I have tried both the beta version of AutoIt and the latest release and neither seem to work. Here is the HTML...

<table cellspacing=0>
<tr>
<td class="ResultLinksCell"><a name="ReportLinkMenu" class="ARABTitle" href="javascript:void(null)" onclick="return NQWPopupMenu(event,'idDownloadLinksMenud:dashboard~p:187d0kpkgsfvqipr~r:jd4pn5gojvgu3ots')">
Download

</a>
<div id="idDownloadLinksMenud:dashboard~p:187d0kpkgsfvqipr~r:jd4pn5gojvgu3ots" class="NQWMenu" onmouseover="NQWMenuMouseOver(event)">
<table cellspacing="0px" class="menuShadowWrapper" >
]<tr><td rowspan="2" colspan="2" class="shadowMenuCell">
<a class="NQWMenuItem" name="SectionElements" href="javascript:void(null);" onclick="NQWClearActiveMenu();Download('saw.dll?Go&amp;_scid=9O9-su0C2Zo&amp;ViewID=dx253adashboardx257epx253a187d0kpkgsfvqiprx257erx253ajd4pn5gojvgu3ots&amp;Action=Download&amp;SearchID=r55l94pr6rcb23b8cic9o8673q&amp;PortalPath=/shared/Xirfx2520Basic/_portal/Amazonx2520Retailx2520Analyticsx2520Basic&amp;Page=Salesx2520x2526x2520Invx2520-x2520Itemx2520Detailx2520(Sourcing)&amp;ViewState=d734cralesu5slb910vmo59qg2&amp;ItemName=SalesInvItemDetailSourcingVendorview&Format=txt&Extension=.csv'); return false">
Download Data (Recommended)
</a>
<a class="NQWMenuItem" name="SectionElements" href="javascript:void(null);" onclick="NQWClearActiveMenu();Download('saw.dll?Go&amp;_scid=9O9-su0C2Zo&amp;ViewID=dx253adashboardx257epx253a187d0kpkgsfvqiprx257erx253ajd4pn5gojvgu3ots&amp;Action=Download&amp;SearchID=r55l94pr6rcb23b8cic9o8673q&amp;PortalPath=/shared/Xirfx2520Basic/_portal/Amazonx2520Retailx2520Analyticsx2520Basic&amp;Page=Salesx2520x2526x2520Invx2520-x2520Itemx2520Detailx2520(Sourcing)&amp;ViewState=d734cralesu5slb910vmo59qg2&amp;ItemName=SalesInvItemDetailSourcingVendorview&Format=excel&Extension=.xls'); return false">
Download to Excel
</a>
<a class="NQWMenuItem"" name="SectionElements" href="javascript:void(null);" onclick="NQWClearActiveMenu();Download('saw.dll?Go&amp;_scid=9O9-su0C2Zo&amp;ViewID=dx253adashboardx257epx253a187d0kpkgsfvqiprx257erx253ajd4pn5gojvgu3ots&amp;Action=Download&amp;SearchID=r55l94pr6rcb23b8cic9o8673q&amp;PortalPath=/shared/Xirfx2520Basic/_portal/Amazonx2520Retailx2520Analyticsx2520Basic&amp;Page=Salesx2520x2526x2520Invx2520-x2520Itemx2520Detailx2520(Sourcing)&amp;ViewState=d734cralesu5slb910vmo59qg2&amp;ItemName=SalesInvItemDetailSourcingVendorview&Format=powerpoint'); return false">

etc.

My program First clicks on the Download button (successfully), At this point, I can then click on a list of items, one being Download to Excel. When I try to click on this using IEAction, I see a window flash up and then it disappears. When I do a manual mouse click on it using MouseClick and the position on the screen, a Download pop-up is displayed. Here is the code that works...

$oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")
If @error <> 0 Then
FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)
Else
_IEAction($oElementy,"focus")
_IEAction($oElementy,"click")
FileWriteLine($logfile, "Click on Download Button. _IEAction = " & @Error)

MouseClick( "Left",68,733)

...

After this the Download pop up is displayed

Here is what I have tried using IE:

; Click on Download button
$oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")
If @error <> 0 Then
FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)
Else
_IEAction($oElementy,"focus")
_IEAction($oElementy,"click")
$oExcelDownload = _IEGetObjByName($oIEb,"SectionElements",11)
MsgBox(0,"","ExcelDownload GetObj error = " & @Error)
MouseMove(68,733)
_IEAction($oExcelDownload,"focus")
_IEAction($oExcelDownload,"click")
MsgBox(0,"","Click Error = " & @Error)

After this, it looks like the download pop up tries to display, but then disappears. All errors displayed, are zero. I have also verified that the "SectionElements" object is the correct one to click on.

After reading an earlier post, I also tried:

; Click on Download button
$oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")
If @error <> 0 Then
FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)
Else
_IEAction($oElementy,"focus")
_IEAction($oElementy,"click")
$oExcelDownload = _IEGetObjByName($oIEb,"SectionElements",11)
MsgBox(0,"","ExcelDownload GetObj error = " & @Error)
$oExcelDownload.fireEvent("onmousedown")
$oExcelDownload.fireEvent("onmouseup")
_IEAction($oExcelDownload, "click")

It seems the earlier post was able to get the above code working but this doesn't seem to work for me with either version of AutoIt. Please let me know if there is any additional information that I can provide to make this easier to debug. Any help would be appreciated.

Link to comment
Share on other sites

It can almost always be made to work by firing the events and manipulating mouse position, but without digging into the Javascript source on the page, there is no way to know what it is expecting.

You are already giving the element focus, you may want to try using a SEND or ControlSend - see the third example for _IEAction for a technique.

Dale

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

Thanks for your help! The ControlSend example 3 helped. I am attaching the working code just in case this might help somebody else that might have this problem.

; Click on Download button
  $oElementy = _IEGetObjByName($oIEb,"ReportLinkMenu")
  If @error <> 0 Then
      FileWriteLine($logfile, "No Data reported for vendor " & $VendorId)
  Else
      ; Click on Download button
      _IEAction($oElementy,"click")
      FileWriteLine($logfile, "Click on Download Button.  _IEAction = " & @Error)
      ; Click on Download to Excel menu item
      $oExcelDownload = _IEGetObjByName($oIEb,"SectionElements",11)
      _IEAction($oExcelDownload,"focus")
      $hwnd = _IEPropertyGet($oIEb, "hwnd")
      ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
      FileWriteLine($logfile, "Click on Download to Excel")
      FileWriteLine($logfile, "MouseClick on Download to Excel")
etc.
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...