Jump to content

Autoit script run correctly the first time but doesnt work the second time


Elina
 Share

Recommended Posts

I am using the below the Autoit script to handle the download popup menu in Internet explorer to save the file.  

Untitled.jpg

Problem: The application searches for the record present in the excel sheet using java and then downloads the pdf from the application ausing autoit. this process keep on iterating.. The autoit script works fine the first time but doesn't work in the second iteration. Please help me with the script..

Autoit script:

Example()

Func Example()

Local $hIE = WinGetHandle("[Class:IEFrame]")
Local $hCtrl = ControlGetHandle($hIE, "", "[ClassNN:Direction1]")

If WinExists($hIE,"") Then
WinActivate($hIE,"")
Send("{ALTDOWN}n{ALTUP}")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("{ENTER}")
Sleep(3000)
EndIf

EndFunc

Exit

 

I have used the Runtime.getRuntime().exec("c:\\...."); to execute the exe file.

Link to comment
Share on other sites

  • Moderators

Not sure why every new person posts in the DEV forum, especially when there is a very clear posting at the top

Quote

Do not create AutoIt-related topics here, use AutoIt General Help and Support 

We even bolded it. Moved to the correct forum.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

It's probably because your "starting point" for your send commands is changed. Probably with that "altup/down" stuff. 

Also, if i understand what you're doing correctly, you're hitting alt+n to select the Run button, then tab to move to the Save button, then enter to select Save. However, here's a more direct way that may solve your problem: 

send("!s") ;sends Alt + s

 

Link to comment
Share on other sites

18 hours ago, robcull said:

It's probably because your "starting point" for your send commands is changed. Probably with that "altup/down" stuff. 

Also, if i understand what you're doing correctly, you're hitting alt+n to select the Run button, then tab to move to the Save button, then enter to select Save. However, here's a more direct way that may solve your problem: 

send("!s") ;sends Alt + s

 

20 hours ago, JLogan3o13 said:

Thanks,

Even send("!s") worked. But my issue is still not resolved yet. let me give you a brief idea on what actually i am trying to do in the web application.

Step1: Using selenium IE web driver, i am login into the application.

step2: In the application, using java i am trying to fetch the first record from the excel sheet and inserting into the search option in the application using selenium.

step 3: After the record is fetched in the application, the report has to be downloaded. On clicking in the download option using selenium, the download popup menu appears in the IE browser.

step3: Using AutoIT, I am trying to save the pdf report.(as per the code mentioned above)

step4: the pdf report is saved to the local system.  

==> this process is repeated from step 2 to step 4 for n number of records present in the excel sheet one by one.

Problem here is the Autoit script isn't executing all the time, it is exceted once or twice and then it stops working due to which the selenium web driver get stuck at that point. 

 

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