Jump to content
Dar

Running autoit script remotely,

Recommended Posts

Dar

I have a script that upload file using the file upload dialog of the browser for test automation.

The script enters a path to the file dialog and click on the open button.

The script runs prefect on my local machine.

I'm using psexec to execute the script remotely, it opens but doing nothing, meaning no interaction is being made with the file upload dialog.

I use powershell script to do this, this is the code:

set-executionpolicy -executionpolicy Bypass

$computer = "QA-VM2"
$user= xxxx
$password = xxxx


try
{

if (test-Connection -Cn $computer -quiet)
  {
   Start-Process C:\Users\qatestagent\Documents\PSTools\PsExec.exe -Verb runas -ArgumentList "\\$computer -u $user -p $password -i cmd /c C:\NewUpload.exe ""test.bat"" ""File Upload"""
  }
}
catch [Exception] 
{
$_.Exception.Message
}
Edited by Dar

Share this post


Link to post
Share on other sites
orbs

hello Dar, welcome to AutoIt and to the forum.

processes running over PsExec can not interact with the desktop. this has nothing to do with AutoIt.

judging by your description, it seems you are going the wrong way about whatever you are trying to do. for example, what do you imagine the remote user is supposed to do while your process is working (assuming it can do what you need)? stare at the screen, watch the upload dialog?

Share this post


Link to post
Share on other sites
Dar

Thanks for the reply!

I'm trying to simulate a file upload.

The file upload dialog is opened, and I need to enter a path to the file bar, and click on the open button.

This is done for testing purposes.

Any directions which way to go from here?  

Share this post


Link to post
Share on other sites
orbs

why over PsExec?

Share this post


Link to post
Share on other sites
Dar

so how you recommend?

Share this post


Link to post
Share on other sites
orbs

let us have some background information, so we can suggest the best way.

on the remote pc there is already a user logged-on, right? and that user is supposed to do something during or after your upload, right?

or are you trying to launch multiple uploads (regardless of user interaction) only to evaluate the robustness of the upload target?

Share this post


Link to post
Share on other sites
Dar

I'm testing the UI of a my website, with selenium remote webdriver.

for one test i'm doing some clicking and then arrive to a file upload dialog, the control of the webdriver stops here.

so here i'm using an autoit script. this part succeeds locally but not remotely, because I need to run the script remotely from the machine that runs the test (this is where psexec comes into play).

So yes, there is a user logged here before, and there is some actions to be made after the upload.

It's just a certain scenario that i want to test on my site.

Share this post


Link to post
Share on other sites
Dar

yes, but again this not my problem.

I already used autoit to extend selenium,it works fine this way you mentioned locally, but I need to run it on a remote machine.

When I use this line:

Runtime.getRuntime().exec(commands);

The file executed locally and not on the remote machine that runs the test.

Edited by Dar

Share this post


Link to post
Share on other sites
orbs

let me clarify: is the RemoteWebDriver working successfully on the remote pc, until the upload dialog?

is so, then the RemoteWebDriver should be able to launch the AutoIt script (or any executable, for that matter) in the context of the remote pc where it is running. but this is going into the internals of Selenium, which i'm not that into. i think youshould consult the Selenium forums.

however, i can suggest this workaround:

on the remote pc:

1) copy the script to the remote pc, so it will be executed locally later.

2) in "All Users" Start Menu or Desktop, place a shortcut (.lnk file) to the now local AutoIt script.

3) assign a keyboard combination to that .lnk

4) on your pc, write and compile an AutoIt script with Send() the keyboard combination.

the above are one-time operations. now, launch PsExec as you do, but do not instruct it to launch the AutoIt script. instead, instruct it to launch the script you wrote in step 4.

crude, but it works. still i think the solution should be within the Selenium environment.

Share this post


Link to post
Share on other sites
Dar

smart solution! i'll try it...

Share this post


Link to post
Share on other sites
Dar

It worked, thank you very much for the help!

Edited by Dar

Share this post


Link to post
Share on other sites
RamyaBhat
On 3/5/2014 at 8:22 PM, Dar said:

It worked, thank you very much for the help!

On 3/5/2014 at 8:22 PM, Dar said:

It worked, thank you very much for the help!

Hi Dar, even i'm facing the same issue. Could you please elaborate on how u were able to resolve this? i'm a bit confused in running an autoIT script with Send(keyboard combinations for the file in Remote machine) from our local. I believe when we run selenium script in Remote and it suddenly encounters Runtime.getRuntime().exec(autoIT script in local), control comes to our local from remote. Now, if the  autoITscript sends some keyboard combinations, how exactly the control goes back to the remote?

Share this post


Link to post
Share on other sites
RAMKI14

Hi Dar,

I am into same kind of situation...testing my web application using selenium...unable to test some part of web application using Selenium code...so opted for AutoIT, it worked fantastically! But only thing is the AutoIT exe files are not running on remote machines, where as it runs fine on local machine...same issue as you have had.

 

You said, Orb's steps worked for you! can you please explain me how to 

 

2) in "All Users" Start Menu or Desktop, place a shortcut (.lnk file) to the now local AutoIt script. (by right clicking on the exe file...I have created a shortcut to my AutoIT exe file)

3) assign a keyboard combination to that .lnk

    How to do this step...steps please

4) on your pc, write and compile an AutoIt script with Send() the keyboard combination.

    How to do this step...steps please

the above are one-time operations. now, launch PsExec as you do, but do not instruct it to launch the AutoIt script. instead, instruct it to launch the script you wrote in step 4.

crude, but it works. still i think the solution should be within the Selenium environment.

 

Your help greatly appreciated! This will save my time.

 

Thanks in advance,

Ramki

Share this post


Link to post
Share on other sites
RAMKI14
18 hours ago, RAMKI14 said:

Hi Dar,

I am into same kind of situation...testing my web application using selenium...unable to test some part of web application using Selenium code...so opted for AutoIT, it worked fantastically! But only thing is the AutoIT exe files are not running on remote machines, where as it runs fine on local machine...same issue as you have had.

 

You said, Orb's steps worked for you! can you please explain me how to 

 

2) in "All Users" Start Menu or Desktop, place a shortcut (.lnk file) to the now local AutoIt script. (by right clicking on the exe file...I have created a shortcut to my AutoIT exe file)

3) assign a keyboard combination to that .lnk

    How to do this step...steps please

 

I HAVE FIGURED IT OUT TO COMPLETE ABOVE 2 STEPS....CAN YOU PLEASE HELP ON BELOW THIS? HOW DID YOU DO THAT?

4) on your pc, write and compile an AutoIt script with Send() the keyboard combination.

    How to do this step...steps please

the above are one-time operations. now, launch PsExec as you do, but do not instruct it to launch the AutoIt script. instead, instruct it to launch the script you wrote in step 4.

crude, but it works. still i think the solution should be within the Selenium environment.

 

Your help greatly appreciated! This will save my time.

 

Thanks in advance,

Ramki

 

Share this post


Link to post
Share on other sites
kantesh

I have a script that install the printer  using the printer installation dialog of the browser for test automation.

The script enters a path to the file dialog and click on the ok button.

The script runs prefect on my local machine.

I'm using Runtime.getRuntime().exec // to execute the script remotely, it opens but doing nothing, meaning no interaction is being made with the file printer installation dialog.

I use selenium and java to do this, this is the code:

  driver.findElement(By.xpath("//a[contains(.,'norprinter9')]")).click();
    Thread.sleep(3000);
    Runtime.getRuntime().exec("C:\\Users\\Administrator\\Desktop\\AUTOIT\\K1.exe");  

   

Share this post


Link to post
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

×