Jump to content

AutoIT not work in Headless mode browsers


saro
 Share

Recommended Posts

Hi Team,

When I run the autoIT script in Jenkins which run selenium regression test in headless mode, file uploading is not happening, when I do the same in browser mode locally its working fine, Do we have any option to work autoit on head less mode or any suggestion?

Link to comment
Share on other sites

Jenkins runs as a service in session 0.  Windows will never be in an Active state, so many functions won't work.  You'll need to provide MUCH more for me to suggest a fix. 

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I have a scenario there I need file uploading functionality which is coded by auto it script in the current framework. The framework did not fail when I execute in my local windows machine. But we are asked to configure this job in Jenkins on AWS windows machine. Jenkins execute my automation testing in head less mode, at the time of auto it script file upload point, its not happening, This is identified by log traces. so my test case fails at the time of verifying the file in application. So my question here is how we can achieve the file upload functionality on head less mode testing in Jenkins?

Link to comment
Share on other sites

@saro, welcome to AutoIt and to the forum.

disclaimer: i know nothing about Jenkins. what i do know, is that AutoIt is fully capable of working headless - when written correctly. i have successfully done extensive browser automation in headless mode. it went so smoothly, that some of my colleagues had the impression i was operating a server-side code ;-)

now, when running AutoIt code in headless mode, there is a simple rule-of-thumb to follow: do not interact with GUI (even if it is occasionally possible). do not wait for a window to become active; do not click buttons, do not read or send text. find the non-interactive alternatives to achieve the same goals.

13 hours ago, jdelaney said:

You'll need to provide MUCH more for me to suggest a fix.

literally: how exactly are you expecting AutoIt to perform the file upload? is Jenkins calling the AutoIt executable with command line parameters specifying the file name and target location? or is there a dialog titled "File Upload" which you expect AutoIt to fill in the details and then click a button titled "Upload"? or what?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Hi @orbs,

Thank you for your detailed reply. I have a web based application where we have file upload button, when click on the button, file upload dialog box open where we need to pass the file name like (c:\file.txt). To achieve this part, I have a java selenium framework, this will call the auto it script after click on upload button like

Runtime.getRuntime().exec(.../autoit.exe c:\file.txt );

Autoit script is written like

Local $hWnd = WinWait("[CLASS:#32770]", "", 10)
ControlFocus($hWnd,"","Edit1")
Sleep(5000)
ControlSetText($hWnd, "", "Edit1", $CmdLine[1])
Sleep(5000)
ControlClick($hWnd, "", "Button1");

Please let me know if you are fine with this info

Link to comment
Share on other sites

Good.   You are using all the proper functions for working with a window in session 0.  Do you know exactly which line is failing?  Next step would be to add logging of returns for each step. 

Another option is to force the selenium scripts to run on a user session with a desktop active.  This works if you don't have security concerns with leaving a VM that won't logout.  You can do this with PAExec or a scheduled task. 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

if you are testing the UI for uploading a file, then follow the advice on the post above. but if the upload is just means to an end, and the important part is not the UI but getting the file uploaded, then use AutoIt to directly upload the file to the target location (or even Windows' built-in ftp.exe utility instead).

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

  • 4 months later...

Hi 

I have an issue using Autoit in Headless mode.

Am using Python and Selenium with Chrome Browser

used Autoit to handle windows security pop-up for one of the URLS.

Its all working fine with browser window mode. When i enable headless The Autoit send funtion to send username and password is not working.

Its sending the username and password any open window rather to headless window

Link to comment
Share on other sites

If you run the selenium scripts on windows server or client, you can use autoitx directly in your selenium scripts. ..wait for window, controlgethandle controlsettext controlclick.  I'm not certain that the windows are created in headless mode though.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...