0

My application has a functionalities like Enroll customer, Enroll card (for the added customers), Enroll offer.

All the things either i can enrool single customer one by one or card one by one etc from the front end browser.

We have automated these things by Selenium. Now there is a utility (vbscript) created for that (UI mode and Non UI mode). you can add n number of customers/cards/offers by providing the txt file (txt file should have all the customer details) as input file in the utility or same way you can run the utility by command prompt (Non UI) with utility name and the filename..

Now I need to write a code for open the utility file and import the txt file and as well as enter the command in the cmd prompt and run this and then go to application (in browser) verify that all are added?

I know that there is limitation on the selenium that it helps you to automate browser side but i heard that there is AutoIt which you can do this. if there is a way in java also fine..

Does anybody know that can we achieve this??

ChanGan
  • 4,254
  • 11
  • 74
  • 135
  • I dont get the part with the vb utility. Are you trying to automate the vb utility by adding customer/cards/offers (through cmd or UI)? AutoIT can definitely automate the cmd part and it might also detect the UI properties as well. You will have to check if AutoIT's Window Info is detecting the properties or not. – LittlePanda Apr 02 '15 at 06:47
  • I'll give little clear on the VB utility.. There is application (exe) is given and if open that, UI will be displayed, i have to give the input file.. without opening the utility you can directly run from the command prompt by providing the path – ChanGan Apr 02 '15 at 06:51
  • The cmd part seems possible with Runtime.exec(). The UI part is possible with AutoIT or even UFT – LittlePanda Apr 02 '15 at 07:06

2 Answers2

1

Selenium can be used for the parts that are automating your web browser whereas AutoIT should be used for automating Windows applications.

This link provides good information on how to use AutoIT alongwith Selenium: http://www.toolsqa.com/selenium-webdriver/autoit-selenium-webdriver/

Here is what you have to do:

Download/install AutoIT
You will be able to create .au3 scripts using AutoIT SciTe Editor Compiling the .au3 script will give you a .exe file Then you can invoke the .exe file from your Selenium script using

Runtime.getRuntime().exec("D:\AutoIt\AutoItTest.exe");

You can get the properties of a window using the AutoIT Window Info (x86) or (x64). Example, title / status bar of a window.

AutoIT also has Au3 Recorder so that you can record your actions that are related to the remote desktop.

Below is a sample script that automates Http authentication:

WinWaitActive("Web page title","","10")
If WinExists("Web page title") Then
Send("userid{TAB}")
Send("password{Enter}")
EndIf

Below script gets the text present in the status bar of Notepad:

WinWaitActive("Untitled - Notepad", "", 30) 
Local $hWnd = WinGetHandle("Untitled - Notepad")
Local $sText = StatusbarGetText("Untitled - Notepad","",2)
ConsoleWrite($sText) 

I hope this information helps!

Since you are looking for a Java solution: Try AutoITx4Java - https://code.google.com/p/autoitx4java/

  1. Download Jacob, AutoIT (refer the above link)
  2. Add jacob.jar and autoitx4java.jar to your library path.
  3. Place the jacob-1.15-M4-x64.dll file in your library path.

Sample Code

File file = new File("lib", "jacob-1.15-M4-x64.dll"); //path to the jacob dll
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());

AutoItX x = new AutoItX();
String notepad = "Untitled - Notepad";
String testString = "this is a test.";
x.run("notepad.exe");
x.winActivate(notepad);
x.winWaitActive(notepad);
x.send(testString);
Assert.assertTrue(x.winExists(notepad, testString));
x.winClose(notepad, testString);
x.winWaitActive("Notepad");
x.send("{ALT}n");
Assert.assertFalse(x.winExists(notepad, testString));
LittlePanda
  • 2,496
  • 1
  • 21
  • 33
0

I am not really clear on your question. But as i understand you can run your utility from cmd prompt, which you can execute from you java code as well. Please check this answer

As you pointed out you can use autoit or sikuli for automating the ui part.

Community
  • 1
  • 1
Shamik
  • 1,591
  • 2
  • 16
  • 36