AutoIt Library: Unterschied zwischen den Versionen

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen
(Weiterleitung nach AutoIt Library/en erstellt)
 
(10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
#redirect [[AutoIt_Library/en]]
== Introduction ==
AutoIt is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys).

AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.

The expecco autoIt plugin wraps some of those low level functions into easier to use building blocks. This makes it a powerful combination:

* allows for non-programmers to create scripts which remote-control other applications

* integrates smoothly with web-application tests (for example, to automate native-window dialog boxes which pop up from web applications - especially: certificate and single-sign on queries)

* integrates smoothly with database, telecom or automation scenarios.

No attempt was made to support AutoIt's scripting facilities. These are better implemented using Expecco's own mechanisms for looping, alternatives, assertions etc.

== Installation ==

The autoIt oackage itself is not part of the expecco installation package. It must be downloaded from the AutoIt web page (https://www.autoitscript.com/site/autoit/downloads at the time this document was written).
If this link does not work, google for "autoit download".
<P>
Download the autoIt package and intall it with its default settings.
Typically, the software is installed in "C:\Program Files\AutoIt3".
The only component needed by expecco is the autoIt dll, which should be in "C:\Program Files\AutoIt3\AutoItX\AutoItX3.dll".
<P>
If this is in your path (try "set" on the cmd.com command line), you are ready to use it. Otherwise, either change the path setting, or go to the expecco dll-mapping settings, and add a corresponding entry to the mapping table:
[[Datei:DLL_AutoIt_Mapping.png]]
This tells expecco, where to find that dll.

== Command Overview ==

The following overview only descripes the most used building blocks.
Please refer to the [http://www.autoitscript.com/autoit3/docs Official AutoIt Documentation] and
especcially [http://www.autoitscript.com/autoit3/docs/functions.htm The Function Reference] for a full list and more detailed description.

=== Connect / Disconnect ===
* [[AutoIt Connect |'''AutoIt [ Connect ]''' ]]<br/> Connects to the remote autoit server or local dll and returns a handle to the interface
* [[AutoIt Disconnect |'''AutoIt [ Disonnect ]''']]<br/> Closes the connection to the interface

=== Window Specific Functions ===
* [[AutoIt WinActivate |'''AutoIt [ Activate ]''' ]]<br/> Activates (gives focus to) a window.
* [[AutoIt WinActive |'''AutoIt [ Active ]''' ]]<br/> Checks to see if a specified window exists and is currently active.
* [[AutoIt WinClose |'''AutoIt [ Close ]''' ]]<br/> Closes a window.
* [[AutoIt WinExists |'''AutoIt [ Exists ]''' ]]<br/> Checks to see if a specified window exists.
* [[AutoIt WinSetState |'''AutoIt [ SetState ]''' ]]<br/> Shows, hides, minimizes, maximizes, or restores a window.
* [[AutoIt WinMinimizeAll |'''AutoIt [ MinimizeAll ]''' ]]<br/> Minimizes all windows.
* [[AutoIt WinMinimizeAllUndo|'''AutoIt [ MinimizeAllUndo ]''']]<br/> Undoes a previous WinMinimizeAll function.
* [[AutoIt WinWait |'''AutoIt [ Wait ]''' ]]<br/> Pauses execution of the script until the requested window exists.
* [[AutoIt WinWaitActive |'''AutoIt [ WaitActive ]''' ]]<br/> Pauses execution of the script until the requested window is active.
* [[AutoIt WinWaitClose |'''AutoIt [ WaitClose ]''' ]]<br/> Pauses execution of the script until the requested window does not exist.
* [[AutoIt WinMenuSelectItem |'''AutoIt [ MenuSelectItem ]''' ]]<br/> Selects a specific menu item.

=== Window Control Specific Functions ===
* [[AutoIt Click |'''AutoIt [ Click ]''']]<br/> Sends a mouse click command to a given control.
* [[AutoIt Send |'''AutoIt [ Send ]''']]<br/> Sends a string as keyboard input to a given control.
* [[AutoIt GetText|'''AutoIt [ GetText ]''']]<br/> Retrieves text from a control.
* [[AutoIt SetText|'''AutoIt [ SetText ]''']]<br/> Sets text of a control.

=== Option Setting ===
* [[AutoIt Opt |'''AutoIt [ Option ]''']]<br/> Changes the operation of various AutoIt functions/parameters.

=== Process Handling ===
* [[AutoIt Run|'''AutoIt [ Run ]''']]<br/> Runs an external program.

== Tips & Tricks ==

=== Local vs. Remote Applications ===
You can access and control both local and remote applications via this plugin. When interfacing to a local application, expecco uses the autoIt-dll to directly interact with the tested application. To control remote applications, the AutoIt proxy "autoitRemoteServer.com" must be up and running on that host(s). This proxy implements a message-passing interface via a socket interface to forward autoIt commands from the expecco-host to the application's host. The proxy must be started on the target host with:
autoitRemoteServer.com hostnameOrIpAddress portNumber

Notice that the "autoitRemoteServer.com" possibly opens a security leak, as it allows for external programs to connect and control/manipulate the windows on the screen. Therefore, it is recommended to restrict the access and make sure that only the test-system on which expecco runs gains access to it. The parameter "''hostnameOrIpAddress''" restricts remote access to that single host. Use "localhost" or "127.0.0.0" if you want to deny any external access, and only allow the expecco which runs on the same host to connect to it. Otherwise specify your own hostname or ip address.
The "portNumber" parameter is optional. The default is 9998.<br/>

So, if the application to be tested executes on "hostA", and expecco on "hostE", open a command interface on "hostA" and enter "<code>autoitRemoteServer.com hostE</code>". Use "hostA" as the destination-parameter of the connect block.

If you use "localhost" as destination parameter to the connect block, the autoIt local interface (without remote proxy) will be used. In that case no autoitRemoteServer needs to be run on the local host. Otherwise the connect block try to connect to autoitRemoteServer on the specified host.<br/>

Please note, that the autoitRemoteServer may provide only a reduced set of the autoIt functions. Please refer to the Interface Plugin Library for more information.

=== Applications and Windows Versions ===

Notice that many Microsoft applications may show different control ids in their components in different Windows versions and/or language settings. For example, the "calculator.exe" application looks similar in a German language setting to its English counterpart. However, the control keys are different. It is important to keep this in mind and prepare the testsuite, for it to remain portable across different (also future) windows versions.
A good strategy is to build an application specific control key library or specify the control keys in an environment. This can then be modified, or loaded depending on the OS version. We highly recommend the use of attachment files to keep that information separate from the actual test sequence.

== Examples ==

==== Waiting for an Application's Window to Appear ====

The following little network waits for a window (given by its window-title) to appear.
It does this in an endless loop, so the caller must take care to shut it down after a while.
Here is a "Wait for Window to Appear" implementation:

[[Datei:AutoIt_WaitForWindow1.png]]

==== Confirming a Password Dialog in a Web-Browser Session ====

Using the previous block, we can automatically answer a password request, which might pop up when a web-application session is started in selenium. The following example is especially interesting, as it combines web-browser interaction, using selenium with low-level windows automation, using AutoIt.

So, we combine the web-login with the dialog-confirmer as follows:

[[Datei:WebLogin_with_ConfirmPassword1.png]]

Notice, that in this real-world example, three autoIt dialog confirmers are started in parallel. They execute concurrently with the web-browser's login procedure. These parallel processing threads are cancelled when the login step has finished. The three confirmers care for different types of boxes which appear depending on the type of browser used: as it happened in that particular application, firefox was asking for the chip-card password, whereas Internet Explorer wanted the user to confirm the use of a particular certificate. Some of these dialogs only appear once per session, as the browsers seem to cache this data. Thus, if the browser does not ask for a password (in a second run, for example), the login step succeeds immediately and terminates the box-wait actions.

The three dialog-confirmer look very similar; here is the "Answer Firefox Password Dialog" block's implementation:
[[Datei:AutoIt_ConfirmPassword1.png]]


<hr>
Back to [[Online_Documentation#Library_and_Plugin_Overview | Online Documentation]].

Aktuelle Version vom 6. Dezember 2016, 19:01 Uhr

Weiterleitung nach:



Copyright © 2014-2024 eXept Software AG