0

I use Watir with IE. On a website, there is a link that, for some reason, it does not work with Watir. The Watir line below causes the screen to flash, while it should download a CSV file.

browser.frame(:id, "ptifrmtgtframe" ).link( :id => 'URL$1' ).click

To replace this command, I used the following AutoIt script, that works:

#include <IE.au3>
$oIE = _IEAttach ("Process Monitor")
$oIE = _IEFrameGetCollection ($oIE, 0)
$oLink = _IEGetObjById( $oIE, "URL$1" )
$x = _IEPropertyGet($oLink, "screenx")
$y = _IEPropertyGet($oLink, "screeny")
MouseMove( $x + 100, $y + 5 ) 
MouseClick( "left" )

Now, I would like to convert this AutoIt script into Watir. The biggest problem is, I cannot get the X and Y of the link. Can you help?

I also checked this example but I get the error message:

I:/watir/abs_pos.rb:47:in '<module:WindowsInput>': uninitialized constant WindowsInput::Win32API (NameError) from I:/watir/abs_pos.rb:46:in '<main>'

I also added require 'win32ole' but it did not help.

I use Win 7 x64, IE 8.

carlo.borreo
  • 1,344
  • 2
  • 18
  • 35
  • I would focus on why you do not get the file download dialog when you click the link. Maybe your code isn't doing it right, maybe there is a popup blocker, or there even could be a defect in Watir. In any case, if you provide a link to the test site or the html code, I could try it. – Dave McNulla Mar 24 '11 at 23:36
  • Dave, I cannot post because it is my company's PeopleSoft installation. However, I noticed that the problem disappeared when I switched to watir-webdriver (the link click works, without code changes) so I won't investigate further. – carlo.borreo Mar 25 '11 at 10:18

1 Answers1

1

My guess would be that you have to fire a JavaScript event: How to find out which JavaScript events fired?.

And, as Dave said, show us the HTML, or provide a link to the page, if it is public.

Community
  • 1
  • 1
Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
  • You are probably right, the link is connected to a JavaScript open that loads a page with the file .csv. However, I noticed that with watir-webdriver the problem disappears, so I won't investigate further. – carlo.borreo Mar 25 '11 at 10:21