AutoIT exe not working in selenium but works normally - selenium

I want to close the print window that is showing after submit a form. I used AutoIT to create an exe to close the window. It is working fine when running seperately but when I include it in selenium it is not working. Below I showing the code usind in selenium to call the AutoIT exe. Pls anyone sugggest a better alternative or help me to solve this issue
// Close the print Window
Runtime.getRuntime().exec("D:\eclipse-workspace\AutoITFiles\cancelPrintwindow.exe");

Based on your file path I assume you are using Java, do you have the correct AutoIt jar and dll files in your project?
You will need the following files as part of your project:
AutoItX4Java.jar (or other version)
jacob.jar
AuotItX3.dll
AutoItX3_64.dll

Related

Selenium Automation + chromedriver

I am trying to automate a web application wherein clicking a link downloads a PDF file. The default behavior of chromedriver should open a pop-up window for confirmation. I am facing issue with the same, In my case the file is directly downloading without prompting.(I need to pop up to change the file name)
My understanding is that there is no easy way to make Selenium download files. Browsers use native dialogs which cannot be controlled by JavaScript.
Why are you downloading a file in the first place?
Check out this for more detail.
This can be set via settings option,
refer the below link https://support.google.com/chrome/answer/95574

Selecting a file in MacOS Finder when running Selenium / Capybara test script

I'm attempting to upload a file on a page that I'm testing. The attach_file method within Capybara will not work here. The reason being that the upload feature is using a JS library named file-uploader here.
I'm actually able to invoke a mouse click in order to open a Finder window (in Mac OS) to allow me to select a file to open, however I'm not sure of how to work within this window. Essentially I'd like to select a file from my desktop and just click 'Open'.
Is there a way for me to work within this window to simply choose a file by its name and then click 'Open'?
I'm working in Firefox.
Dragging the file from my desktop into a div would also work, but I can not find a way to do that in Capybara either.
Thank you.
Selenium is a browser automation tool & as such any interaction with other components of operating systems is not possible. Once a browser opens a file open/Finder window, it's no longer the browser that you're interacting with. There are tools out there which can handle them, but i am not familiar enough to give a detailed response. Google the Robot framework, or AutoIt for starters.
Alternatively, since it's a JS library you're dealing with which handles the upload, you MAY be able to use the JavascriptExecutor to call library functions directly, which doesn't simulate the user experience, but may be enough to get past your hurdle.

Automate File Upload using Selenium Webdriver C# on ASP.NET file upload control

I have a ASP.NET file upload control which opens a window when you click the upload button to select the file you want to upload. But the problem is that the webdriver cant recognize the window and therefore cant select the file to be uploaded.
I have found numerous solutions in the stackoverflow which use sendkeys to enter the path of file. I think that works when you have html file upload control. In my case I have the ASP.NET file upload control and it doesn not have a text box where i can enter the file path using sendkeys.
how do i solve this?? Any suggestions ?
You can use the Windows Automation library to identify windows. UIspy can be used to identify the properties of a window. Add the System.Windows.Automation reference to your project.

Unable to call autoit executable in Junit Selenium test

I hope everyone is having a most excellent day and any and all help is appreciated.
I am running an automated Selenium Junit4(remote control) test in internet explorer 7. To do this I utilized the following tutorial: http://qtp-help.blogspot.com/2009/07/selenium-handle-dialogs.html.
The test is being run from my springsource ide on my mac and is being executed through my virtual box ( windows xp sp 3 ) to internet explorer 7. When the test is run, following the directions in the tutorial explicitly, when it gets to the step that is marked with an asterisk:
Thread.sleep(2000);
String browser = selenium.getEval("navigator.userAgent");
if(browser.contains("IE")){
System.out.print("Browser= IE "+browser);
* String[] dialog = new String[]{ "Save_Dialog_IE.exe","Download","Save" };
Runtime.getRuntime().exec(dialog);
I get the error: can not find file or directory
If I call the Save_Dialog_IE.exe inside of a command prompt manually the process runs and interaction with the IE7 browser dialogs are successful. But when attempting to call it while executing the selenium test it does not.
The only step in the tutorial I am not sure I did correctly was placing the executable (Save_Dialog_IE.exe in the project directory). I am not sure exactly where in the project to place the file. I placed it in both the root directory of the project as well as the folder in the project where I created the class for the junit test. A little fuzzy as to exactly where it needs to go.
Anybody got any ideas how to make this work? Or even any idea's as to how to interact with IE7 browser dialogs running a selenium test on a mac to a virtual VMware box running windows xp sp3?
The .exe file needs to be in the same directory as from where your program (its own .exe is run). I'm not sure how it works with selenium, but you may just need to do:
1) The .exe file needs to go in the root of your project. Then you have to get its properties, and make sure that the .exe is copied to the project output. Usually this is the /bin/Debug/ (or /Release/) folder, but I'm not sure how that works with selenium.
Or 2) Put the .exe file along with your selenium test application, wherever that is.

Selenium- Issue-Clicking on windows pop-ups

I am using selenium to record some tests. We have a save to pdf button on our application that generates the windows open/ save or in firefox the ok/cancel windows pop up,
The issue is that i can;t get selenium to record my ok or cancel action since i think it is not a javascript window?
Does anyone know the command to do that?
thanks
Sadly, it's not possible to interact with such windows at the moment.
A good workaround for saving files dialog is to save the various parameters (local directory, etc) and tell your browser to not prompt for them, so the window won't pop at all.
See http://wiki.openqa.org/display/SEL/Selenium+Core+FAQ#SeleniumCoreFAQ-Whatyoucan%27tdowithSelenium
Create a separate firefox profile(command to open profile manager:-firefox -P) with the settings you want(you can give settings like where to download and save a file of a particular type automatically without prompting) and instruct your server to use that profile using the command : java -jar 'your server ' -firefoxProfileTemplate 'path_for_firefox_profile'