https://doc.expecco.de/w2.x/api.php?action=feedcontributions&user=Ani&feedformat=atomexpecco Wiki (Version 2.x) - Benutzerbeiträge [de]2024-03-29T12:20:24ZBenutzerbeiträgeMediaWiki 1.33.0https://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16014Mobile Testing Plugin/en2019-05-24T12:34:30Z<p>Ani: /* Recorder */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Run|Run Demo]], iOS: [[#Step_1:_Demo_Run_2|Run Demo]]).<br />
<br />
===Extended View===<br />
The extended view of the connection editor can be obtained either by clicking on ''Edit'' in the third step or at any time via the corresponding menu item if you have started the editor via the plugin menu. This view displays a list of all configured Appium Capabilities. You can add, change or remove further entries to this list. To add a capability, select it from the drop-down list of the input field. In this list all known capabilities are sorted into the categories ''Common'', ''Android'' and ''iOS''. If you have selected a capability, a short information text is displayed. You can also enter a capability manually in the field. Then click on ''Add'' to add the capability to the list. There you can set the value in the right column. To delete an entry, select it and click on ''Remove''. With ''Back'' you leave the extended view.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Running Appium Servers ==<br />
In the menu of the Mobile Testing Plugin you will find the entry ''Appium-Server...''. This opens a window with an overview of all Appium servers started by expecco and on which port they are running. By clicking on the icon in the column ''Show Log'' you can view the logfile of the corresponding server. This is deleted when the server is shut down. With the icons in the column ''Exit'' the corresponding server can be terminated. However, this is prevented if expecco still has an open connection via this server.<br />
<br />
You can also start servers here. Use the input fields to configure the server address. You can also leave the fields blank to use the default values. Please note that servers can only be started locally and the selected port must not be occupied. Typically the odd port numbers from 4723 are used. The following port number is also required when connecting to a device, which could lead to conflicts with the even numbers.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
In the menu of the Mobile Testing Plugin you will also find the entry ''Close all Connections and Servers''. This is intended for cases where connections or servers cannot be terminated in any other way. If possible, always terminate connections in the GUI browser or by executing a corresponding block. Servers that you have started in the server overview should be terminated there; servers that were started with a connection are automatically terminated with this connection.<br />
<br />
Note that only servers started and managed by expecco are listed in the overview. Possible other Appium servers that were started in a different way are not recognized.<br />
<br />
== Recorder ==<br />
If the GUI browser is connected to a device, the integrated recorder can be used to record a test section with that device. To start the recorder, select the appropriate connection in the GUI browser and click the Record button. A new window opens for the recorder. The recorded actions are created in the GUI browser work area. It is therefore possible to edit the recorded data in parallel.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16013Mobile Testing Plugin/en2019-05-24T12:05:17Z<p>Ani: /* Running Appium Servers */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Run|Run Demo]], iOS: [[#Step_1:_Demo_Run_2|Run Demo]]).<br />
<br />
===Extended View===<br />
The extended view of the connection editor can be obtained either by clicking on ''Edit'' in the third step or at any time via the corresponding menu item if you have started the editor via the plugin menu. This view displays a list of all configured Appium Capabilities. You can add, change or remove further entries to this list. To add a capability, select it from the drop-down list of the input field. In this list all known capabilities are sorted into the categories ''Common'', ''Android'' and ''iOS''. If you have selected a capability, a short information text is displayed. You can also enter a capability manually in the field. Then click on ''Add'' to add the capability to the list. There you can set the value in the right column. To delete an entry, select it and click on ''Remove''. With ''Back'' you leave the extended view.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Running Appium Servers ==<br />
In the menu of the Mobile Testing Plugin you will find the entry ''Appium-Server...''. This opens a window with an overview of all Appium servers started by expecco and on which port they are running. By clicking on the icon in the column ''Show Log'' you can view the logfile of the corresponding server. This is deleted when the server is shut down. With the icons in the column ''Exit'' the corresponding server can be terminated. However, this is prevented if expecco still has an open connection via this server.<br />
<br />
You can also start servers here. Use the input fields to configure the server address. You can also leave the fields blank to use the default values. Please note that servers can only be started locally and the selected port must not be occupied. Typically the odd port numbers from 4723 are used. The following port number is also required when connecting to a device, which could lead to conflicts with the even numbers.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
In the menu of the Mobile Testing Plugin you will also find the entry ''Close all Connections and Servers''. This is intended for cases where connections or servers cannot be terminated in any other way. If possible, always terminate connections in the GUI browser or by executing a corresponding block. Servers that you have started in the server overview should be terminated there; servers that were started with a connection are automatically terminated with this connection.<br />
<br />
Note that only servers started and managed by expecco are listed in the overview. Possible other Appium servers that were started in a different way are not recognized.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16012Mobile Testing Plugin/en2019-05-24T11:58:04Z<p>Ani: /* Running Appium Servers */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Run|Run Demo]], iOS: [[#Step_1:_Demo_Run_2|Run Demo]]).<br />
<br />
===Extended View===<br />
The extended view of the connection editor can be obtained either by clicking on ''Edit'' in the third step or at any time via the corresponding menu item if you have started the editor via the plugin menu. This view displays a list of all configured Appium Capabilities. You can add, change or remove further entries to this list. To add a capability, select it from the drop-down list of the input field. In this list all known capabilities are sorted into the categories ''Common'', ''Android'' and ''iOS''. If you have selected a capability, a short information text is displayed. You can also enter a capability manually in the field. Then click on ''Add'' to add the capability to the list. There you can set the value in the right column. To delete an entry, select it and click on ''Remove''. With ''Back'' you leave the extended view.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Running Appium Servers ==<br />
In the menu of the Mobile Testing Plugin you will find the entry ''Appium-Server...''. This opens a window with an overview of all Appium servers started by expecco and on which port they are running. By clicking on the icon in the column ''Show log'' you can view the logfile of the corresponding server. This is deleted when the server is shut down. With the icons in the column ''Exit'' the corresponding server can be terminated. However, this is prevented if expecco still has an open connection via this server.<br />
<br />
You can also start servers here. Use the input fields to configure the server address. You can also leave the fields blank to use the default values. Please note that servers can only be started locally and the selected port must not be occupied. Typically the odd port numbers from 4723 are used. The following port number is also required when connecting to a device, which could lead to conflicts with the even numbers.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
In the menu of the Mobile Testing Plugin you will also find the entry ''Close all Connections and Servers''. This is intended for cases where connections or servers cannot be terminated in any other way. If possible, always terminate connections in the GUI browser or by executing a corresponding block. Servers that you have started in the server overview should be terminated there; servers that were started with a connection are automatically terminated with this connection.<br />
<br />
Note that only servers started and managed by expecco are listed in the overview. Possible other Appium servers that were started in a different way are not recognized.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16011Mobile Testing Plugin/en2019-05-24T11:47:13Z<p>Ani: /* Laufende Appium-Server */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Run|Run Demo]], iOS: [[#Step_1:_Demo_Run_2|Run Demo]]).<br />
<br />
===Extended View===<br />
The extended view of the connection editor can be obtained either by clicking on ''Edit'' in the third step or at any time via the corresponding menu item if you have started the editor via the plugin menu. This view displays a list of all configured Appium Capabilities. You can add, change or remove further entries to this list. To add a capability, select it from the drop-down list of the input field. In this list all known capabilities are sorted into the categories ''Common'', ''Android'' and ''iOS''. If you have selected a capability, a short information text is displayed. You can also enter a capability manually in the field. Then click on ''Add'' to add the capability to the list. There you can set the value in the right column. To delete an entry, select it and click on ''Remove''. With ''Back'' you leave the extended view.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Running Appium Servers ==<br />
In the menu of the Mobile Testing Plugin you will find the entry ''Appium-Server...''. This opens a window with an overview of all Appium servers started by expecco and on which port they are running. By clicking on the icon in the column ''Show log'' you can view the logfile of the corresponding server. This is deleted when the server is shut down. With the icons in the column ''Exit'' the corresponding server can be terminated. However, this is prevented if expecco still has an open connection via this server.<br />
<br />
You can also start servers here. Use the input fields to configure the server address. You can also leave the fields blank to use the default values. Please note that servers can only be started locally and the selected port must not be occupied. Typically the odd port numbers from 4723 are used. The following port number is also required when connecting to a device, which could lead to conflicts with the even numbers.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
In the menu of the Mobile Testing Plugin you will also find the entry ''Close all connections and servers''. This is intended for cases where connections or servers cannot be terminated in any other way. If possible, always terminate connections in the GUI browser or by executing a corresponding block. Servers that you have started in the server overview should be terminated there; servers that were started with a connection are automatically terminated with this connection.<br />
<br />
Note that only servers started and managed by expecco are listed in the overview. Possible other Appium servers that were started in a different way are not recognized.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16010Mobile Testing Plugin/en2019-05-24T10:02:34Z<p>Ani: /* Erweiterte Ansicht */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Run|Run Demo]], iOS: [[#Step_1:_Demo_Run_2|Run Demo]]).<br />
<br />
===Extended View===<br />
The extended view of the connection editor can be obtained either by clicking on ''Edit'' in the third step or at any time via the corresponding menu item if you have started the editor via the plugin menu. This view displays a list of all configured Appium Capabilities. You can add, change or remove further entries to this list. To add a capability, select it from the drop-down list of the input field. In this list all known capabilities are sorted into the categories ''Common'', ''Android'' and ''iOS''. If you have selected a capability, a short information text is displayed. You can also enter a capability manually in the field. Then click on ''Add'' to add the capability to the list. There you can set the value in the right column. To delete an entry, select it and click on ''Remove''. With ''Back'' you leave the extended view.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16009Mobile Testing Plugin/en2019-05-24T09:31:03Z<p>Ani: /* Step 3: Server Settings */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Run|Run Demo]], iOS: [[#Step_1:_Demo_Run_2|Run Demo]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16008Mobile Testing Plugin/en2019-05-24T09:29:40Z<p>Ani: /* Schritt 3: Servereinstellungen */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 3: Server Settings===<br />
In the last step, a list of all the capabilities that result from your entries in the previous steps is first displayed in the upper part. If you are familiar with Appium and want to set additional capabilities that are not covered by the connection editor, you can click on ''Edit'' to open the extended view. See the section below for more information.<br />
<br />
If you enter settings for the GUI browser, you can enter the ''Connection name'' with which the connection is displayed. This is also the name under which devices can use this connection when it is established. If you leave the field blank, a name will be generated. To specify the address for the Appium server, you get the local default address and addresses already used for selection. If you check the box for ''Start on demand'', expecco tries to start an Appium server at the given address when connecting, if none is running there yet. This server will then also be shut down when the connection is terminated. This only works for local addresses. Make sure that you only use port numbers that are free. It is best to only use odd port numbers from the standard port 4723. The following port number is also used when establishing a connection, which could otherwise lead to conflicts.<br />
<br />
Depending on how you opened the dialog, there are now different buttons to close it. In any case you have the option to save. This opens a dialog where you can either select an open project to save the settings there as an attachment, or choose to save it to a file that you can then specify. Saving does not close the dialog, allowing you to select another option.<br />
<br />
If you have opened the editor for establishing a connection, you can finally click on ''Connect'' or ''Start and connect server'', depending on whether the check mark for server start is set. For changing or copying a connection in the GUI Browser, this option is called ''Apply'', since in this case only the connection entry is changed or created, but the connection setup is not started. If necessary, you can do this afterwards via the context menu. If you have changed capabilities of an existing connection, a dialog then prompts you to decide whether these changes should be applied directly by closing the connection and establishing the new connection or not. In this case, the changes only take effect after you reestablish the connection.<br />
<br />
To use the connection editor, also read the corresponding section in the respective tutorial in step 1. (Android: [[#Step_1:_Demo_Execute|Execute Demo]], iOS: [[#Step_1:_Demo_Execute_2|Execute Demo]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16007Mobile Testing Plugin/en2019-05-24T09:23:55Z<p>Ani: /* Step 2: Select App */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16006Mobile Testing Plugin/en2019-05-24T09:21:05Z<p>Ani: /* Schritt 2: App auswählen */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 2: Select App===<br />
Here you can enter information about the app to be tested. You can decide if you want to use an app that is already installed on the device or if you want to install an app for the test. Select the appropriate tab above. Depending on whether you selected an Android or an iOS device in the previous step, the required input will change.<br />
<br />
*'''Android'''<br />
**''App on the Device''<br />
**:If you have selected a connected device in the first step, the packages of all installed apps are automatically retrieved and you can select from the drop-down lists. The installed apps are divided into third-party packages and system packages; select the appropriate package list. This selection does not belong to the settings, but only provides the corresponding package list. You can use the filter to further narrow down the list and then select the desired package. The activities of the selected package are also automatically retrieved and made available as a drop-down list. Select the activity you want to start. As a rule, an activity is automatically entered from the list. If you are not using a connected device, you must enter the package and the activity manually.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. If you are using a local Appium server, you can use the right button to navigate to the App installation file and enter this path. If possible, the corresponding package and the activity are also entered in the fields below. However, this entry is not necessary.<br />
<br />
*'''iOS'''<br />
**''App on the Device''<br />
**:Specify the bundle ID of an installed app. You can find out the IDs of the installed apps using Xcode, for example. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window will open displaying a list of connected devices. If you select your device, you will see a list of the apps you have installed in the overview.<br />
**''Install App''<br />
**:Under ''App'', enter the path to an app. The path must be valid for the Appium server being used. You can also specify a URL. For the requirements of apps for real devices, please read the section [[#iOS-Ger.C3.A4t_and_App_Preparing|iOS-Devices and App preparing]].<br />
<br />
In the lower part you can specify whether the app should be reset or uninstalled when the connection is terminated, and whether it should be reset initially. Again, the corresponding capability is not set if you select ''(Default)''. With ''Next'' you get to the next step.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16005Mobile Testing Plugin/en2019-05-24T09:07:39Z<p>Ani: /* Step 1: Select Device */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Note on unlocking</span>: In newer Android versions the developer options are no longer offered in the settings at first. If your Android device does not show an entry for "''Developer options''" in the settings, first select the entry "''Phone info''", then "''SoftwareVersionsInfo''" and click on the entry "''BuildVersion''" several times.<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16004Mobile Testing Plugin/en2019-05-24T09:01:29Z<p>Ani: /* Step 1: Select Device */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*No devices found<br />
*:expecco could not find any Android devices.<br />
*:To automatically configure a connection to a device, make sure<br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*No available devices found<br />
*:expecco could not find any available Android devices. But not available ones were found, e.g. with the status "unauthorized".<br />
*:To configure a connection to a device automatically, make sure that <br />
*:*it is connected<br />
*:*it is turned on<br />
*:*that it has an appropriate adb driver installed<br />
*:*it is enabled for debugging (see below).<br />
*:To view unavailable devices, enable this option below.<br />
*Connection lost<br />
*:expecco has lost the connection to the adb server. Try to re-establish the connection by clicking on the button.<br />
*Connection failed<br />
*:expecco could not connect to the adb server. Possibly it is not running or the specified path is not correct.<br />
*:Check the adb configuration in the settings and try to start the adb server and establish a connection by clicking on the button.<br />
*Connect ...<br />
*:expecco connects to the adb server. This may take a few seconds.<br />
*Start adb-Server ...<br />
*:expecco starts the adb-Server. This may take a few seconds.<br />
<br />
<!--With ''Automation by'' you can specify, which automation engine is to be used. If you leave the setting at ''(Default)'' the corresponding capability is not set at all. Otherwise Appium, Selendroid and from expecco 2.11 XCUITest are available. Selendroid is usually only used for Android devices prior to version 4.1.-->With ''Next'' you get to the next step. If you enter settings for the GUI browser, this is only possible once a device has been selected.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16003Mobile Testing Plugin/en2019-05-24T08:41:51Z<p>Ani: /* Schritt 1: Gerät auswählen */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Step 1: Select Device ===<br />
In the upper part you will see a list of all connected Appium devices that are detected. With the checkbox below you can hide devices that are detected but not ready. If you want to enter a device that is not connected, you can create it with the corresponding button ''Enter Android device'' or ''Enter iOS device''. However, you need to know the required properties of your device. The device is then created in a second device list and can be selected there. If no list with connected elements can be displayed, various messages are displayed instead:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16001Mobile Testing Plugin/en2019-05-23T10:01:29Z<p>Ani: /* Connection Editor */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#''Advanced View'': Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=16000Mobile Testing Plugin/en2019-05-23T10:00:22Z<p>Ani: /* Connection Editor */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#Advanced View: Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15999Mobile Testing Plugin/en2019-05-23T09:59:59Z<p>Ani: /* Dialoge des Mobile Testing Plugins */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialogs of the Mobile Testing Plugin =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Load settings from file'': Allows to open a saved settings file (*.csf). Its settings are transferred to the dialog. Entries already made without conflict are retained.<br />
#''Load settings from attachment'': Allows you to open an attachment with connection settings from an open project. These settings are applied to the dialog. Entries already made without conflict are retained.<br />
#''Save settings to file'' and<br />
#''Save settings to attachment'': Here you can save the entered settings to a file (*.csf) or create them as an attachment in an open project. Both options have a delayed menu in which you can choose to save only a certain part of the settings. (Only visible when creating settings.)<br />
#Advanced View: Allows you to switch to the advanced view to make additional settings. Read more about this at the end of this chapter. (Only visible when creating settings.)<br />
#''Help'': A help text for the respective step is shown or hidden on the right side.<br />
<br />
The dialog is divided into three steps. In the first step you select the device you want to use, in the second step you select which App should be used and in the last step the settings for the Appium server are made.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15998Mobile Testing Plugin/en2019-05-23T09:50:47Z<p>Ani: /* Verbindungseditor */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Connection Editor ==<br />
You can use the Connection Editor to quickly define, change, or establish connections. Depending on the task, the dialog has small differences and is opened differently:<br />
*If you want to establish a connection, access the dialog in the GUI browser by clicking on ''Connect'' and then selecting ''Mobile Testing''.<br />
*To change or copy an existing connection in the GUI browser, select it, right-click and select ''Edit Connection'' or ''Copy Connection'' from the context menu.<br />
*If you do not want to create connection settings for the GUI browser but for use in a test, choose ''Create Connection Settings'' from the Mobile Testing Plugin menu.... This only allows you to create the settings for a connection without creating a connection in the GUI browser.<br />
<br />
The Connection Editor menu has several buttons, some of which are only visible when creating connection settings:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Delete Settings'': Resets all entries. (Only visible when creating settings.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15983Mobile Testing Plugin/en2019-05-22T14:02:55Z<p>Ani: /* Schritt 5: Test vervollständigen */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15982Mobile Testing Plugin/en2019-05-22T14:00:16Z<p>Ani: /* Step 4: Create another block */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15981Mobile Testing Plugin/en2019-05-22T13:48:16Z<p>Ani: /* Schritt 4: Noch einen Baustein erstellen */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15980Mobile Testing Plugin/en2019-05-22T13:42:29Z<p>Ani: /* Step 3: Customizing XPath Using the GUI Browser */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15931Mobile Testing Plugin/en2019-05-21T14:30:53Z<p>Ani: /* Schritt 3: XPath anpassen mithilfe des GUI-Browsers */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI_Browser|Customizing_XPath using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15924Mobile Testing Plugin/en2019-05-20T14:58:35Z<p>Ani: /* Step 3: Customizing XPath Using the GUI Browser */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath Using the GUI-Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15923Mobile Testing Plugin/en2019-05-20T14:58:05Z<p>Ani: /* Step 3: Customizing XPath Using the GUI Browser */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_using_the_GUI-Browsers|Customizing XPath using the GUI-Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15922Mobile Testing Plugin/en2019-05-20T14:47:32Z<p>Ani: /* Step 2: Creating a Block with the Recorder */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15921Mobile Testing Plugin/en2019-05-20T13:41:06Z<p>Ani: /* Schritt 2: Einen Baustein mit dem Recorder erstellen */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar, you can select the tool (1) with which you want to enter an action. The tool ''Auto'' is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
Now a new test for the recognition of correct GTIN-13 codes shall be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15856Mobile Testing Plugin/en2019-05-16T13:55:34Z<p>Ani: /* Step 1: Run Demo */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment ''(expeccoMobileDemo-debug.apk)''. With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15855Mobile Testing Plugin/en2019-05-16T13:54:54Z<p>Ani: /* Step 1: Run Demo */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (expeccoMobileDemo-debug.apk). With the provided module Export Demo App you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15854Mobile Testing Plugin/en2019-05-16T13:53:44Z<p>Ani: /* Step 1: Run Demo */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we start with the rest of the test-suite, first configure the connection and which device you want to use.<br />
You want to use. Now open the GUI browser (1) and select the entry Mobile Testing (3) under Connect (2) (Fig. 2) to open the connection dialog.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15853Mobile Testing Plugin/en2019-05-16T13:51:38Z<p>Ani: /* Step 1: Run Demo */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15852Mobile Testing Plugin/en2019-05-16T13:45:12Z<p>Ani: /* First steps with iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Device and App preparing]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15851Mobile Testing Plugin/en2019-05-16T13:40:54Z<p>Ani: /* First steps with iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Device_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15829Mobile Testing Plugin/en2019-05-14T15:05:54Z<p>Ani: /* Step 1: Run Demo */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15828Mobile Testing Plugin/en2019-05-14T15:03:39Z<p>Ani: /* First steps with Android */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#Preparing an iOS-Device_and_App|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15827Mobile Testing Plugin/en2019-05-14T15:01:07Z<p>Ani: /* First steps with Android */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15826Mobile Testing Plugin/en2019-05-14T15:00:47Z<p>Ani: /* First steps with Android */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see[[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15825Mobile Testing Plugin/en2019-05-14T14:59:49Z<p>Ani: /* First steps with Android */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see[[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15824Mobile Testing Plugin/en2019-05-14T14:54:50Z<p>Ani: /* Step 1: Run Demo */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (Fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer on which your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app. <br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15823Mobile Testing Plugin/en2019-05-14T14:46:19Z<p>Ani: /* First steps with iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15822Mobile Testing Plugin/en2019-05-14T14:44:36Z<p>Ani: /* First steps with iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (siehe [[#iOS-Ger.C3.A4t_and_App_Preparing|Preparing an iOS-Device and App]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15821Mobile Testing Plugin/en2019-05-14T14:42:13Z<p>Ani: /* First steps with iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_and_Setup|Installation and Setup]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15820Mobile Testing Plugin/en2019-05-14T14:39:51Z<p>Ani: /* First steps with iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to your Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] to your Mac. Since the app is a debug build, you still need to sign it for your device (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Now start an Appium server on your Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15819Mobile Testing Plugin/en2019-05-14T14:23:47Z<p>Ani: /* Step 3: Customizing XPath Using the GUI Browser */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select ''Save device settings'' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
Es wird vorausgesetzt, dass Sie das Kapitel [[#Installation_und_Aufbau|Installation und Aufbau]] bereits gelesen und die nötigen Vorbereitungen für die Verwendung von iOS-Geräten unter Mac OS abgeschlossen haben. Schließen Sie das Gerät, das Sie verwenden wollen, an den Mac an. Laden Sie die iOS-Version der [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] auf den Mac herunter. Da es sich bei der App um einen Debug-Build handelt, müssen Sie sie noch für Ihr Gerät signieren (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Starten Sie nun einen Appium-Server auf dem Mac.<br />
<br />
=== Schritt 1: Demo ausführen ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15818Mobile Testing Plugin/en2019-05-14T14:20:23Z<p>Ani: /* Step 3: Customizing XPath Using the GUI Browser */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath using the GUI Browsers]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
Es wird vorausgesetzt, dass Sie das Kapitel [[#Installation_und_Aufbau|Installation und Aufbau]] bereits gelesen und die nötigen Vorbereitungen für die Verwendung von iOS-Geräten unter Mac OS abgeschlossen haben. Schließen Sie das Gerät, das Sie verwenden wollen, an den Mac an. Laden Sie die iOS-Version der [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] auf den Mac herunter. Da es sich bei der App um einen Debug-Build handelt, müssen Sie sie noch für Ihr Gerät signieren (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Starten Sie nun einen Appium-Server auf dem Mac.<br />
<br />
=== Schritt 1: Demo ausführen ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15817Mobile Testing Plugin/en2019-05-14T14:19:29Z<p>Ani: /* XPath anpassen mithilfe des GUI-Browsers */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
Es wird vorausgesetzt, dass Sie das Kapitel [[#Installation_und_Aufbau|Installation und Aufbau]] bereits gelesen und die nötigen Vorbereitungen für die Verwendung von iOS-Geräten unter Mac OS abgeschlossen haben. Schließen Sie das Gerät, das Sie verwenden wollen, an den Mac an. Laden Sie die iOS-Version der [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] auf den Mac herunter. Da es sich bei der App um einen Debug-Build handelt, müssen Sie sie noch für Ihr Gerät signieren (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Starten Sie nun einen Appium-Server auf dem Mac.<br />
<br />
=== Schritt 1: Demo ausführen ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Customizing XPath using the GUI Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15816Mobile Testing Plugin/en2019-05-14T14:16:10Z<p>Ani: /* Step 2: Creating a Block with the Recorder */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting ''Close connection'' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
Es wird vorausgesetzt, dass Sie das Kapitel [[#Installation_und_Aufbau|Installation und Aufbau]] bereits gelesen und die nötigen Vorbereitungen für die Verwendung von iOS-Geräten unter Mac OS abgeschlossen haben. Schließen Sie das Gerät, das Sie verwenden wollen, an den Mac an. Laden Sie die iOS-Version der [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] auf den Mac herunter. Da es sich bei der App um einen Debug-Build handelt, müssen Sie sie noch für Ihr Gerät signieren (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Starten Sie nun einen Appium-Server auf dem Mac.<br />
<br />
=== Schritt 1: Demo ausführen ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= XPath anpassen mithilfe des GUI-Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15815Mobile Testing Plugin/en2019-05-14T08:18:19Z<p>Ani: /* Erste Schritte mit iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting 'Close connection' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> First steps with iOS ==<br />
Es wird vorausgesetzt, dass Sie das Kapitel [[#Installation_und_Aufbau|Installation und Aufbau]] bereits gelesen und die nötigen Vorbereitungen für die Verwendung von iOS-Geräten unter Mac OS abgeschlossen haben. Schließen Sie das Gerät, das Sie verwenden wollen, an den Mac an. Laden Sie die iOS-Version der [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] auf den Mac herunter. Da es sich bei der App um einen Debug-Build handelt, müssen Sie sie noch für Ihr Gerät signieren (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Starten Sie nun einen Appium-Server auf dem Mac.<br />
<br />
=== Schritt 1: Demo ausführen ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= XPath anpassen mithilfe des GUI-Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15814Mobile Testing Plugin/en2019-05-14T08:11:41Z<p>Ani: /* Dialoge des Mobile Testing Plugins */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting 'Close connection' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> Erste Schritte mit iOS ==<br />
Es wird vorausgesetzt, dass Sie das Kapitel [[#Installation_und_Aufbau|Installation und Aufbau]] bereits gelesen und die nötigen Vorbereitungen für die Verwendung von iOS-Geräten unter Mac OS abgeschlossen haben. Schließen Sie das Gerät, das Sie verwenden wollen, an den Mac an. Laden Sie die iOS-Version der [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo-App] auf den Mac herunter. Da es sich bei der App um einen Debug-Build handelt, müssen Sie sie noch für Ihr Gerät signieren (siehe [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]]). Starten Sie nun einen Appium-Server auf dem Mac.<br />
<br />
=== Schritt 1: Demo ausführen ===<br />
Starten Sie expecco und öffnen Sie die Testsuite ''m03_expeccoMobileDemoIOS.ets'' über die Schaltfläche ''Beispiel aus Datei'' (Abb. 1). Ab expecco 2.11 befindet sich diese im Unterordner ''mobile''. Ansonsten laden Sie die Testsuite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] auf den Rechner, auf dem sich Ihre expecco-Installation befindet, und öffnen diese. In dieser Testsuite befindet sich bereits ein vorgefertigter Testplan mit einigen Testfällen für diese App.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Bevor wir uns mit dem weiteren Inhalt der Testsuite beschäftigen, konfigurieren Sie zuerst die Verbindung und welches Gerät Sie benutzen wollen. Öffnen Sie nun den GUI-Browser (1) und wählen Sie unter ''Verbinden'' (2) den Eintrag ''Mobile Testing'' (3) (Abb. 2), um den Verbindungsdialog zu öffnen.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Hier können Sie ein iOS-Gerät nur von Hand eintragen. Wählen Sie dazu ''iOS-Gerät eingeben'' (Abb. 3). Den Namen und die iOS-Version des Geräts können Sie dessen Eigenschaften entnehmen. Um die Gerätekennung des Geräts zu erfahren, öffnen Sie auf dem Mac in Xcode das Fenster Devices (Command-Shift-2). Dort werden alle angeschlossenen Geräte sowie die zur Verfügung stehenden Simulatoren angezeigt. Hier sehen Sie auch die Gerätekennung (udid) Ihres Geräts und welche Apps installiert wurden. Nachdem Sie das Gerät im Verbindungseditor eingegeben haben, wählen Sie es in der Liste aus und klicken Sie dann auf Weiter.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Als nächstes geben Sie an, welche App Sie verwenden wollen. Dabei können Sie wählen, ob Sie eine App starten möchten, die bereits auf dem Gerät installiert ist (''App auf dem Gerät'') oder ob eine App installiert und gestartet werden soll (''App installieren''). Für den Fall, dass Sie eine bereits installierte App benutzen wollen, müssen Sie deren Bundle-ID angeben. Diese erfahren Sie ebenfalls im Devices-Fenster von Xcode. Für die Demo-App lautet sie beispielsweise ''de.exept.expeccoMobileDemo''.<br />
<br />
Für dieses Tutorial soll die Demo-App erst installiert werden. Wählen Sie also ''App installieren'' aus und tragen Sie bei App den Pfad zu der Datei auf dem Mac ein (Abb. 4). Wenn Sie expecco 2.11 verwenden, können Sie auf dieser Seite auch die Team-ID angeben, die für iOS-Verbindungen angibt, welches Zertifiat verwendet werden soll. Falls Sie bereits in den [[#Konfiguration_des_Plugins|Plugin-Einstellungen]] eine ID angegeben haben, wird diese verwendet. Sie wird hier grau dargestellt, solange Sie keinen anderen Wert angeben. Klicken Sie nun auf ''Weiter''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
Auf der letzten Seite sehen Sie eine Übersicht aller bisherigen Angaben (1) (Abb. 5). Unterhalb der Capabilityliste können Sie einen Namen für die Verbindung angeben, unter dem sie im GUI-Browser angezeigt wird (2). Außerdem lässt sich eine Verbindung über diesen Namen identifizieren und in Bausteinen verwenden; der Name muss daher eindeutig sein. Falls Sie keinen Namen angeben, wird generisch einer erzeugt. Geben Sie als Namen ''expeccoMobileDemo'' ein. Im Feld darunter ist die Adresse zum Appium-Server einzutragen (3). Wenn Sie den Appium-Server mit Standardeinstellungen gestartet haben, müssen Sie dazu nur in der Standardadresse (unterster Eintrag der Vorschlagsliste) ''localhost'' durch die IP-Adresse des Macs ersetzen (im Bild ''172.23.1.49''). Um sicher zu gehen, auf welchem Port der Appium-Server lauscht, sehen Sie in dessen Ausgabe. Dort finden am Anfang die Zeile<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
Steht hier am Ende nicht der Standardport ''4723'' ändern Sie diese Angabe entsprechend ebenfalls in der Konfiguration.<br />
<br />
Wenn die Option ''Bei Bedarf starten'' (4) aktiviert ist, überprüft expecco, ob an der Adresse bereits ein Appium-Server läuft, und startet und beendet ihn bei Bedarf automatisch. Das ist allerdings nur für lokale Serveradressen möglich, schalten Sie diese Option daher ab.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Klicken Sie nun auf ''Speichern'' (5) um die Einstellungen für die Testausführung zu speichern. Einstellungen können als Anhang einer Testsuite oder in eine externe Datei gespeichert werden (Abb. 6). Falls Sie mehrere Projekte gleichzeitig offen haben, können Sie in der Liste das Projekt auswählen, in dem der Anhang angelegt werden soll. Klicken Sie auf ''Speichern'' im Bereich ''Einstellungen im Anhang speichern'' und geben Sie als Name ''expeccoMobileDemo'' an. Klicken Sie nun auf ''Verbinden'' (6) um mit der angegebenen Konfiguration eine Verbindung herzustellen.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
Der Verbindungsaufbau kann eine Weile dauern. Wenn Sie die Server-Adresse korrekt angegeben haben, sollten Sie in der Ausgabe des Appium-Servers den Verbindungsversuch erkennen. Auf Ihrem iOS-Gerät sollte dabei die App gestartet werden. Passiert nichts auf dem Gerät, kann es daran liegen, dass entweder das Gerät oder die App nicht gefunden wird. Versucht Appium hingegen, die App zu starten und dies schlägt fehl, ist wahrscheinlich die App falsch signiert. Deinstallieren Sie in diesem Fall die App, damit sie mit einer neuen Signatur wieder installiert werden kann.<br />
<br />
Warten Sie bis die Verbindung aufgebaut ist und im GUI-Browser angezeigt wird. Nun wissen Sie, dass die Konfiguration funktioniert. Die gespeicherten Einstellungen sollen nun für den Test verwendet werden, der dann die gleiche Verbindung aufbaut. Wählen Sie die Verbindung im GUI-Browser aus, machen Sie einen Rechtsklick und wählen Sie im Kontextmenü ''Verbindung abbauen'', damit es zu keinem Konflikt kommt. Wechseln Sie dann zurück zum Reiter der Testsuite.<br />
<br />
In der Testsuite wurden die Einstellungen als Anhang ''expeccoMobileDemo'' angelegt (Abb 7). Wählen Sie den Baustein ''Connect'' (1) aus und wechseln Sie rechts zur Ansicht ''Netzwerk'' (2). Ziehen Sie per Drag-and-drop die Einstellungen in das Netzwerk des Bausteins (3). Verbinden Sie den Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[1]'' des Bausteins ''Connect from File'' (4). Mit ''Übernehmen'' (5) bestätigen Sie die Änderungen. Dieser Baustein wird zu Beginn des Tests die Verbindung zur App herstellen.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Wechseln Sie nun zum Testplan ''Demo-Test'' (1) (Abb. 8). Dieser Testplan enthält bereits einige fertige Testfälle. Vor und nach der Ausführung (2) ist außerdem jeweils ein Baustein eingetragen: Der eben bearbeitete Baustein ''Connect'' für den Aufbau und der Baustein ''Disconnect'' für den Verbindungsabbau. Durch das Eintragen der beiden Bausteine an dieser Stelle geschieht der Verbindungsabbau insbesondere auch dann, wenn der Test vorzeitig abgebrochen wird, z. B. weil einer der Testfälle fehlschlägt.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Jetzt können Sie den Testplan ''Demo-Test'' starten, indem Sie auf den grünen Play-Knopf (3) klicken. Der Testplan sollte ohne Fehler durchlaufen.<br />
<br />
=== Schritt 2: Einen Baustein mit dem Recorder erstellen ===<br />
Mit Hilfe des integrierten Recorders lassen sich einfach Ausführungssequenzen aufnehmen und in einem Baustein speichern. Dafür muss eine Verbindung zu einem Testgerät bestehen, mit dessen Hilfe der Test erstellt wird.<br />
<br />
Um eine Verbindung aufzubauen, wechseln Sie zurück zum GUI-Browser. In diesem ist noch die Verbindung eingetragen, die Sie zuvor angelegt haben. Da für die Verbindung im Testlauf derselbe Name verwendet wurde, wurden die Einstellungen damit überschrieben (In unserem Fall waren die Einstellungen ohnehin identisch). Die Verbindung ist zur Zeit nicht aktiv, da sie am Ende der Ausführung abgebaut wurde. Die Einstellungen sind dort aber noch eingetragen. Um die Verbindung mit dieser Konfiguration wieder aufzubauen, wählen Sie sie aus, gefolgt von einem Rechtsklick und ''Verbinden''.<br />
<br />
Warten Sie, bis die Verbindung aufgebaut ist (1) und drücken Sie dann den Aufnahme-Knopf (2), um eine Aufzeichnung zu starten (Abb. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
Es öffnet sich ein Fenster mit dem Mobile Testing Recorder (Abb. 10). Dieser zeigt einen Screenshot des verbundenen Geräts. Über diese Anzeige können Sie das Gerät fernsteuern. Dabei wird jede Aktion, die Sie ausführen, im Hintergrund aufgezeichnet.<br />
<br />
In der oberen Menüleiste können Sie das Werkzeug auswählen (1), mit dem Sie eine Aktion eingeben möchten. Als Voreinstellung ist das Werkzeug ''Auto'' ausgewählt. Sie können damit bestimmte Aktionen aufzeichnen, indem Sie mit dem Mauszeiger entsprechende Gesten auf der Anzeige ausführen. Wenn Sie zum Beispiel mit der linken Maustaste lange klicken, entspricht das einem langen Antippen des Elements an dieser Stelle. Anstatt die gewünschte Aktion mit der entsprechenden Geste zu bestimmen, können Sie diese alternativ auch manuell auswählen.<br />
<br />
Es soll nun ein neuer Test für das Erkennen korrekter GTIN-13-Codes aufgenommen werden. Klicken Sie zunächst in der Anzeige kurz auf den Button ''GTIN-13 (EAN-13)'' (2) der App um einen entsprechenden Klick auf dem Gerät auszulösen. Während der Ausführung dieser Aktion wird der Rahmen des Recorders kurzzeitig rot. Falls der Recorder danach nicht die aktuelle Ansicht der App darstellen sollte, klicken Sie im Recorder auf das Aktualisierungssymbol (3).<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Anschließend soll im Eingabefeld der neuen Seite eine korrekte GTIN-13 eingegeben werden. Führen Sie dazu einen Rechtsklick auf dem Eingabefeld (1) aus und wählen Sie im Kontextmenü die Aktion ''Text setzen'' (2) (Abb. 11). Geben Sie in den sich daraufhin öffnenden Dialog eine beliebige gültige Artikelnummer im GTIN-13-Format ein, bspw. ''4006381333986'' (3). Dieser Text wird nun in der App gesetzt.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Klicken Sie nun auf ''Verify'' (1) (Abb. 12). In der App erscheint nun als Ergebnis ''OK'' (2). Der Test soll feststellen, ob tatsächlich dieses Ergebnis angezeigt wird. Nach einem Rechtsklick darauf können Sie im Kontextmenü die Aktion ''Attribut zusichern'' (3) auswählen. Wählen Sie im Dialog, der sich daraufhin öffnet, die Eigenschaft ''value'' (4) aus und bestätigen Sie mit ''OK'' (5). Dieses Mal wird keine Aktion auf dem Gerät ausgelöst, sondern nur ein Baustein aufgezeichnet, der fehlschlägt, sollte das Ergebnis vom erwarteten Wert ''OK'' abweichen.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Schließen Sie nun den Recorder. Im ''Arbeitsbereich'' des GUI-Browsers sehen Sie, dass für jede der aufgenommenen Aktionen ein Baustein angelegt wurde (Abb. 13). Sie können nun testen, ob sich das Aufgenommene wieder abspielen lässt. Dazu müssen Sie zunächst die App auf Ihrem Gerät in den Anfangszustand zurückbringen, indem Sie auf dem Gerät die Schaltfläche ''Home'' oben links benutzen. Klicken Sie dann in expecco auf den grünen Play-Knopf (1). Wird alles grün, war die Ausführung erfolgreich. Erstellen Sie nun daraus einen neuen Baustein in der Testsuite, indem Sie auf das Bausteinsymbol (2) in der rechten oberen Ecke klicken. Geben Sie ihm den Namen ''GTIN_Verify_OK'' (3) und bestätigen Sie (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Bauen Sie nun die Verbindung ab, indem Sie die Verbindung auswählen, rechtsklicken und im Kontextmenü ''Verbindung abbauen'' auswählen.<br />
<br />
Wechseln Sie zurück zum Reiter der Testsuite. Dort wurde der neue Baustein angelegt. Wählen Sie wieder den Testplan ''Demo-Test'' aus und fügen Sie den aufgenommenen Testfall ''GTIN_Verify_OK'' per Drag-and-drop am Ende des Testplans hinzu. Übernehmen Sie die Änderung und starten Sie erneut. Der Testplan sollte wieder ohne Fehler durchlaufen.<br />
<br />
=== Schritt 3: XPath anpassen mithilfe des GUI-Browsers ===<br />
Ihr neuer Baustein funktioniert auf anderen Geräten möglicherweise nicht. Die verwendeten Elemente werden über einen XPath adressiert und dieser kann auf anderen Geräten nicht stimmen. Lesen Sie dazu den Abschnitt [[#XPath_anpassen_mithilfe_des_GUI-Browsers|XPath anpassen mithilfe des GUI-Browsers]]. Falls Ihnen ein weiteres Gerät zur Verfügung steht, können Sie nun versuchen, die Pfade in Ihren erstellten Bausteinen zu verallgemeinern. Sie können diesen Schritt aber auch überspringen.<br />
<br />
Wenn es Ihnen schwerfällt, verkürzte Pfade zu finden, orientieren Sie sich dabei an den Pfaden der bereits vorhandenen Bausteine. Starten Sie den Test erneut. Sollte der Test jetzt fehlschlagen, überprüfen Sie die Pfade noch einmal im GUI-Browser.<br />
Um den Test nun auf einem zweiten Gerät auszuführen, öffnen Sie im Menü ''Erweiterungen'' > ''Mobile Testing'' > ''Verbindungseinstellungen erstellen''. Sie erhalten einen Dialog ähnlich zum Verbindungsdialog. Allerdings können Sie hier nur Einstellungen erstellen und speichern aber keine Verbindung herstellen. Sie haben jedoch die Möglichkeit, einzelne Aspekte der Einstellungen zu speichern wie bspw. nur das Gerät. Geben Sie das neue Gerät ein und wählen Sie es aus. Klicken Sie länger auf das Symbol zum Speichern im Anhang bis sich das verzögerte Menü öffnet und wählen Sie hier ''Geräte-Einstellungen speichern'' (Abb. 14). Benennen Sie den Anhang am besten nach dem Gerät. Danach können Sie den Dialog wieder schließen.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Wählen Sie den Baustein ''Connect'' aus und ziehen Sie die Einstellungen für das neue Gerät in dessen Netzwerk. Verbinden Sie nun dessen Ausgangspin ''pathName'' mit dem Eingangspin ''stringOrFilename[2]'' des Bausteins ''Connect from File''. Der Baustein Connect from File liest die Angaben an den Eingangspins von oben nach unten ein, mehrfache Eigenschaften werden dabei ersetzt. In diesem Fall werden also die Einstellungen zum verwendeten Gerät ersetzt, während die übrigen Einstellungen gleich bleiben. Wenn Sie die Pfade geschickt gewählt haben, wird der Test nun auch auf dem anderen Gerät erfolgreich ablaufen.<br />
<br />
=== Schritt 4: Noch einen Baustein erstellen ===<br />
Falls sich gleiche Abläufe im Test wiederholen, können Sie dafür bereits erstellte Bausteine wieder-verwenden oder abwandeln. Der in Schritt 2 erstellte Baustein prüft die Erkennung korrekter GTIN-13-Codes. Es fehlt noch ein Test, der umgekehrt das Erkennen eines falschen GTIN-13-Codes prüft. Die Struktur der beiden Tests ist identisch, sie unterscheiden sich lediglich in ihren Parametern. Kopieren Sie daher den Baustein ''GTIN_Verify_OK'' und benennen Sie die Kopie in ''GTIN_Verify_NOT_OK'' um. Ändern Sie die Eingabe der GTIN-13 in einen falschen Code zum Beispiel durch Ändern der letzten Ziffer (''4006381333987'') und setzen Sie den Überprüfungswert der Ausgabe auf ''NOT OK'' (Abb. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Fügen Sie diesen neuen Test ebenfalls zum Testplan Demo-Test hinzu und setzen Sie ihn ans Ende. Führen Sie den Testplan aus, aber vergessen Sie nicht, vorher die Verbindung im GUI-Browser abzubauen.<br />
<br />
Der neue Test wird fehlschlagen, weil Ihr aufgenommener Baustein nicht wieder zur Startseite der App zurückkehrt, die Tests aber jeweils von dort aus starten. In den anderen Bausteinen ist dies bereits berücksichtigt; sie führen abschließend immer den Baustein ''Back to main menu'' aus. Sie sehen das, indem Sie einen der anderen Bausteine, z. B. ''GTIN_Calculate'', auswählen und auf seine Schema-Ansicht wechseln. Dort steht der Baustein ''Back to main menu'' im Feld ''Nach Ausführung'' (Abb. 16). Wie beim entsprechenden Feld beim Testplan wird auch dieser Baustein immer am Ende ausgeführt, unabhängig davon, ob der Test erfolgreich verläuft oder abbricht. Ergänzen Sie diesen Eintrag nun in Ihren Bausteinen ''GTIN_Verify_OK'' und ''GTIN_Verify_NOT_OK''. Wählen Sie dazu den Baustein aus und ziehen Sie in der Schema-Ansicht den Baustein ''Back to main menu'' einfach auf das Eingabefeld ''Nach Ausführung''. Nun können Sie den Testplan starten und alle Tests sollten wieder problemlos ausgeführt werden.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Schritt 5: Test vervollständigen ===<br />
Für die Activity IBAN sind bereits alle Antwortmöglichkeiten der App mit Testfällen abgedeckt. In der GTIN-13-Activity werden ein korrekter und ein fehlerhafter Code getestet und eine Prüfziffer berechnet, das Verhalten der App bei Eingaben falscher Länge wird aber bisher nicht getestet (Bei Verify '''Input must be exactly 13 digits''. und ''…12 digits''. bei Calculate). Die Activity zum Prüfen der Seriennummern von Eurobanknoten wird noch gar nicht getestet. Wie bei der IBAN können hier drei Fälle auftreten: eine korrekte Seriennummer wurde eingegeben (Antwort: ''OK''), eine falsche Seriennummer wurde eingegeben (Antwort: ''NOT OK'') oder die Angabe entspricht nicht dem Format (Antwort: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). Sie können die Testabdeckung jetzt noch erweitern, indem Sie entsprechende Testfälle erstellen. Die Bausteine dafür können Sie wie in Schritt 2 mit dem Recorder erstellen und die XPaths bei Bedarf verallgemeinern. Wenn Sie mit dem grundsätzlichen Umgang mit expecco vertraut sind, können Sie Bausteine natürlich auch ohne Recorder erstellen, indem Sie sie manuell aus vorhandenen Bausteinen der Bibliothek zusammensetzen. Sie können auch beide Vorgehensweisen nach Belieben kombinieren.<br />
<br />
Beachten Sie, dass die hier vorgestellten Testfälle jeweils nur einzelne Eingaben prüfen. Wenn Sie Testfälle für Ihre eigenen Apps schreiben, wollen Sie vermutlich engmaschiger testen, indem Sie noch weitere unterschiedliche Werte eingeben, die insbesondere auch Randfälle enthalten.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= XPath anpassen mithilfe des GUI-Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15813Mobile Testing Plugin/en2019-05-14T08:08:13Z<p>Ani: /* Tutorial */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#First_steps_with_Android|First steps with Android]]'''<br />
*'''[[#First_steps_with_iOS|First steps with iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting 'Close connection' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= XPath anpassen mithilfe des GUI-Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15812Mobile Testing Plugin/en2019-05-13T15:18:36Z<p>Ani: /* Erste Schritte mit iOS */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#Erste_Schritte_mit_Android|Erste Schritte mit Android]]'''<br />
*'''[[#Erste_Schritte_mit_iOS|Erste Schritte mit iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting 'Close connection' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= XPath anpassen mithilfe des GUI-Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Anihttps://doc.expecco.de/w2.x/index.php?title=Mobile_Testing_Plugin/en&diff=15811Mobile Testing Plugin/en2019-05-13T15:15:53Z<p>Ani: /* Step 3: Customizing XPath Using the GUI Browser */</p>
<hr />
<div>= Introduction =<br />
With the Mobile Testing Plugin applications can be tested on Android and iOS devices. This includes both real and emulated devices. It does not matter whether real mobile devices or emulated devices are used. The plugin can (and usually is) used in conjunction with the [[Expecco_GUI_Tests_Extension_Reference|GUI-Browser]], which supports the creation of tests. It can also be used to record test procedures.<br />
<br />
The [http://appium.io/ Appium] is used to connect to the devices. Appium is a free open source framework for testing and automating mobile applications.<br />
<br />
We recommend editing the [[#Tutorial|Tutorial]] to familiarize yourself with the Mobile Plugin. This tutorial leads step by step through the creation of a test case using an example and explains the necessary basics.<br />
<br />
= Installation and Setup =<br />
To use the ''Mobile Testing Plugin'', you must have installed expecco together with the corresponding plugin, and you need the appropriate licenses. expecco communicates with the mobile devices via an Appium server, which either runs on the same computer as expecco, or on a second computer. This must be accessible for expecco.<br />
<br />
'''Installation overview for expecco 18.1:'''<br />
* Appium-Server<sup>a</sup> 1.6.4 for Android<br />
* Appium-Server<sup>b</sup> 1.8.0 for iOS<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7, 8 or 9<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 9.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.11:'''<br />
* Appium-Server<sup>ab</sup> 1.6.4<br />
for Android-devices starting with version 4.3:<br />
* Java JDK<sup>a</sup> Version 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices starting with version 9.3:<br />
* Xcode 8.3.x<br />
* Apple-Developer-Certificate incl. matching private key<br />
* Provisioning Profile with the mobile devices used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br />
<br />
'''Installation overview for expecco 2.10:'''<br />
* Appium-Server<sup>ab</sup> 1.4.16<br />
for Android-devices starting with version 2.3.3 up to version 6.0:<br />
* Java JDK Version<sup>a</sup> 7 or 8<br />
* Android SDK<sup>a</sup><br />
for iOS-devices up to version 9.3:<br />
* Xcode 7.3.x<br />
* Apple-Developer-Certificate <sup>c</sup> incl. matching private key<br />
* Provisioning Profile<sup>c</sup> for the mobile devices to be used<br />
(<sup>a</sup>) contained in Mobile Testing Supplement<br><br />
(<sup>b</sup>) contained in Mobile Testing Supplement for Mac OS<br><br />
(<sup>c</sup>) in order to sign the appp<br />
<br />
Please note that due to the requirements iOS devices can only be controlled from a Mac. expecco can then communicate over the network with the Appium server on the Mac to test on the iOS devices connected there. The following explains how to install Appium and other necessary applications for Windows and Mac OS.<br />
<br />
[[Datei:MobileTestingAufbau.png | 400px]]<br />
<br />
== Windows ==<br />
The easiest way is to install everything from our Mobile Testing Supplement:<br />
*'''expecco 18.2''': [http://download.exept.de/transfer/h-expecco-18.2.0/MobileTestingSupplement.exe Mobile Testing Supplement 1.7.3.0]<br />
:This installs Appium in the version 1.8.1. In addition, an installation of ''Android Debug Bridge'' and ''Google USB Driver'' ([https://gsmusbdrivers.com/download/adb-fastboot-drivers/ adb-setup-1.4.3]) is offered. This covers drivers for a broad range of Android devices, and you won't have to install an individual driver for each device. A '''JDK is not contained anymore''', you have to download it on your own, e.g. from [https://www.oracle.com/technetwork/java/javase/downloads/index.html Oracle].<br />
*expecco 18.1: same procedure as for expecco 2.11<br />
*expecco 2.11: [http://download.exept.de/transfer/h-expecco-2.11.1/MobileTestingSupplement_1.6.0.2_Setup.exe Mobile Testing Supplement 1.6.0.2]<br />
:This installs a Java JDK Version 8, android-sdk and Appium Version 1.6.4. The supplement also offers a universal adb driver ([http://download.clockworkmod.com/test/UniversalAdbDriverSetup.msi ClockworkMod]). This driver supports a wide range of Android Devise, and avoids the need to search for individual device-specific drivers.<br />
*expecco 2.10: [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_1.5.0.0_Setup.exe Mobile Testing Supplement 1.5.0.0]<br />
:It installs a Java JDK version 8, android-sdk and Appium version 1.4.16. During the installation the graphical user interface of Appium is started, you can close this window immediately. The supplement also offers a universal adb driver (ClockworkMod). This combines drivers for a wide range of Android devices so that you do not have to search for and install a separate driver for each device.<br />
<br />
When Appium is started, it may happen that the Windows firewall blocks access to the Node-Server, and expecco cannot start/connect to the Appium server. To verify correct operation after the installation, run the ''appium.cmd'' program found in the ''appium'' folder of the Mobile Testing Supplement. If the Appium server can be started, it should also work from expecco. If the Windows firewall is logging in, allow access.<br />
<br />
== Mac OS ==<br />
Note: the following can be ignored if you do not plan to test iOS (iPhone) devices. The Mac setup is not needed for Android devices.<br />
<br />
=== expecco 18.1 ===<br />
We provide an updated [http://download.exept.de/transfer/h-expecco-18.1.0/Mobile_Testing_Supplement_for_Mac_OS_1.1.94.tar.bz2 Mobile Testing Supplement für Mac OS (1.1.94)], which includes Appium 1.8.0. For devices with IOS 11, you'll also need Xcode 9, with at least a corresponding minor version number, i.e. Xcode 9.3 für iOS 11.3. Other than that, the setup is the same as with expecco 2.11.<br />
<br />
=== expecco 2.11 ===<br />
The Mac used should run OS X 10.12 (Sierra) and Xcode 8.3 or later as operating system version. You can install a current version of Xcode from the App Store. In addition, a Java installation is required by Appium. For that, install a JDK in Version 7 or 8. Then install Appium 1.6.4 using our [http://download.exept.de/transfer/h-expecco-2.11.1/Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2 Mobile Testing Supplements for Mac OS (1.0.94)]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. An appropriate command in a shell might look like this:<br />
<br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.94.tar.bz2<br />
<br />
''Note: For the automation of iOS devices from version 10, an installation of a comparable new Xcode 8 is necessary (for iOS 10.2 at least Xcode 8.2, for iOS 10.3 at least Xcode 8.3, etc.), which may not run on older operating systems. So if you switch to a newer iOS version, you usually need a newer Xcode version as well, which may require an update of the operating system (see also Xcode Versions).<br />
<br />
[https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]).''<br />
<br />
If Xcode 8.3 or later is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
If there is not enough new Xcode configured as default, you have to specify the corresponding path via the environment variable ''DEVELOPER_DIR'' in Appium. For example, if you have Xcode installed in ''/Applications/Xcode-8.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-8.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.6.4<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium cannot find your Xcode installation, a message appears like:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
To establish a test connection with a device, you need an Apple account. For evaluation you can use a free account. This has the disadvantage that created profiles are only valid for one week and must be recreated afterwards. Also be careful when sharing the account, as certificates may be revoked or invalidated by automatic generation. As a result, apps that have already been signed can no longer be used.<br />
<br />
First, connect the device you want to use to your Mac via USB. Start Xcode and open ''Preferences''. Go to the Accounts page and create an entry with your account. You can then click on ''Manage Certificates...'' to see the certificates that belong to that account. To run tests, you need an iOS Development Certificate and the associated private key. If you do not already have one, create one. If you already have one, but it is not in your keychain (indicated by "Not in Keychain"), you can import it. In any case, open the keychain management on your Mac and select the keychain ''login''. If you want to import a certificate from a PKCS#12-Datei (Endung typischerweise .p12), you can do this via the menu File > ''Import objects''. If you don't know where the certificate is stored, you can also revoke it in Xcode and recreate it in your keychain. However, only do this if you know that the old certificate is no longer in use because it can no longer be used afterwards. Now the keychain should contain an iOS development certificate. From the right-click menu, select Information. Under the details of the certificate you will find the Team ID, which is referred to here as the Organizational Unit. Enter it in the Team ID field of the plug-in's settings, see [[#Konfiguration_des_Plugins|Konfiguration des Plugins]].<br />
<br />
Return to Xcode und select ''Open...'' in the menue ''File'', to open the WebDriverAgent project. This is found in the Mobile Testing Supplements folder under<br />
''<nowiki>Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj</nowiki>''<br />
<br />
[[Datei:MobileTestingWebDriverAgentXcode.png]]<br />
<br />
Select ''WebDriverAgentLib'' and the page ''General''. In the section ''Signing'' set the option ''Automatically manage signing'' and then select a team. Now switch to ''WebDriverAgentRunner'' and also to the ''General'' page. Set automatic signing here as well and select your team here as well. Here you should see errors indicating that no Provisioning Profiles have been created or found. Therefore, go to the ''Build Settings'' page and look for the entry ''Product Bundle Identifier'' in the ''Packaging'' section. Change this from com.facebook.WebDriverAgentRunner to something Xcode accepts by changing the prefix. Xcode can now generate a matching Provisioning Profile and the errors on the General page should disappear. After that you can quit Xcode.<br />
<br />
If you now connect to your device from expecco, the WebDriverAgent will be installed and started on it and then switch to the app to be tested. On the device, however, the execution of the WebDriverAgent must still be trusted. To do this, open the settings during the connection setup on the device and then the entry Device management under General. This entry is only visible if a developer app is installed on the device. You may therefore have to wait until the WebDriverAgent is installed before the entry appears. Select the entry of your Apple account and trust it. Since the WebDriverAgent will be uninstalled again if the start did not work, you have to do this during the connection setup. If this is too hectic for you, you can also execute the following code:<br />
<br />
''xcodebuild -project Mobile_Testing_Supplement/lib/node_modules/appium-1.6.4-beta/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test''<br />
<br />
This installs the WebDriverAgent on the device without deleting it again. Refer to the [https://support.apple.com/en-us/HT204460 Dokumentation von Apple] for details on installing and trusting such apps.<br />
<br />
=== expecco 2.10 ===<br />
The Mac used should run OS X 10.11.5 (El Capitan) or later as operating system version. To automate with iOS devices up to version 9.3, you need to install Xcode 7.3, which does not run on older operating systems (see also [https://en.wikipedia.org/wiki/Xcode#Version_comparison_table Xcode-Versionen]). Install Xcode from the App Store. Appium also requires a Java installation. Install a JDK in version 7 or 8. You can now install Appium 1.4.16 using our [http://download.exept.de/transfer/h-expecco-2.10.0/Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2 Mobile Testing Supplements für Mac OS]. After you have downloaded it, you can move it to a directory of your choice (e.g. your home directory) and unpack it there. A suitable command in a shell could look like this: <br />
tar -xvpf Mobile_Testing_Supplement_for_Mac_OS_1.0.tar.bz2<br />
If Xcode 7.3 is your default Xcode installation, you can start Appium directly:<br />
Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
If Xcode 7.3 is not configured as the default Xcode, you must specify the appropriate path to Appium using the ''DEVELOPER_DIR'' environment variable. For example, if you have Xcode installed in ''/Applications/Xcode-7.3.app'', you can start Appium this way:<br />
DEVELOPER_DIR="/Applications/Xcode-7.3.app/Contents/Developer" Mobile_Testing_Supplement/bin/start-appium-1.4.16<br />
You can use this command to find out what is set as the default Xcode installation in your system:<br />
xcode-select -p<br />
If Appium does not find your Xcode installation, an error message like this appears when connecting:<br />
''<blockquote>org.openqa.selenium.SessionNotCreatedException - A new session could not be created. (Original error: Could not find path to Xcode, environment variable DEVELOPER_DIR set to: /Applications/Xcode.app but no Xcode found)</blockquote>''<br />
In such a case, restart Appium by specifying a valid ''DEVELOPER_DIR''.<br />
<br />
== Konfiguration of Plugins ==<br />
Before you get started, you should check the settings of the Mobile Testing Plugin and adjust them if necessary. Open in the menu the item "''Extras''" > "''Settings'"' and there under "''Extensions''" the entry "''Mobile Testing''" (s. fig.). By default, these paths are found automatically (1). To adjust a path manually, deactivate the corresponding check mark to the right of it. You will see a drop-down list with some paths to choose from. If an entered path is wrong or cannot be found, the field is marked red and a message appears. Make sure that all paths are specified correctly.<br />
<br />
[[Datei:MobileTestingEinstellungen.png | thumb | 400px | Konfiguration des Plugins]]<br />
<br />
*'''appium''': Enter here the path to the executable file with which Appium can be started in the command line. Under Windows this file will usually be called "<code>appium.cmd</code>". This path is used when expecco starts an Appium server.<br />
*'''node''': Enter the path to the executable file that starts Node (also called (auch "Node.js" genannt). This path is passed to Appium when a server is started so that Appium can find it independently of the PATH variable. Under Windows this file is usually called "<code>node.exe</code>".<br />
*'''JAVA_HOME''': Enter the path to a JDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable. To set which Java should be used by expecco, set this path in the Java Bridge settings.<br />
*'''ANDROID_HOME''': Enter the path to an Android SDK here. This path is passed on to each Appium server. Leave the field blank to use the value from the environment variable.<br />
*'''adb''': This is the path to the adb command. Under Windows the file is called adb.exe. This file is used by expecco, for example, to get the list of connected devices. This path should be selected automatically, because the command is used in the ANDROID_HOME directory. This is also used by Appium. If expecco and Appium use different versions of adb, conflicts may occur.<br />
*'''android.bat''': This file is only needed to start the AVD and the SDK Manager. The file in the ANDROID_HOME directory will be searched automatically.<br />
*'''aapt''': Enter the path to the aapt command here. Under Windows this file is called ''aapt.exe''. expecco uses aapt only in the connection editor to read the package and activities of an apk file. The file in the ANDROID_HOME directory will be searched automatically.<br />
<br />
[[Datei:MobileTestingJavaBridgeEinstellungen.png | thumb | 400px | Konfiguration des JDKs]]<br />
<br />
From expecco 2.11 there is a field ''Team-ID''. If you run iOS tests, enter the team ID of your certificate here. This is used for every iOS connection, unless you change the value in the connection settings. How to get the Team ID is described in the [[#expecco_2.11|Installation auf Mac OS mit expecco 2.11]] section. With expecco 2.10 you can enter the Team-ID only for each connection setting separately as capability. However, you must use the [[#Extended_View|Extended View]] to do this. Enter here the Capability ''xcodeOrgId'' and set as value the Team-ID of the certificate.<br />
<br />
The server address setting at the bottom of the page refers to the behavior of the connection editor. It checks at the end whether the server address ends in ''/wd/hub'' as this is the usual form. If not, a dialog asks how to react. The defined behavior can be viewed and changed here.<br />
<br />
Also switch to the entry ''Java Bridge'' (see figure). Here you have to specify the path to your Java installation, which is used by expecco. Enter a JDK here. If you want to use the one from the Mobile Testing Supplement under Windows, the path is<br />
<nowiki>C:\Program Files (x86)\exept\Mobile Testing Supplement\jdk</nowiki><br />
You can also use the system settings.<br />
<br />
== Prepare Android Device ==<br />
If you connect an Android device under Windows, you may still need an adb driver for the device. You can usually find a suitable driver on the manufacturer's website. If you have installed the universal driver from the Mobile Testing Supplement, everything should already work for most devices. In some cases, Windows will automatically try to install a driver when you connect the device for the first time. <br />
Attention: Before you can control a mobile device with the Appium plugin, you have to allow this debugging!<br />
<br />
For Android devices, you can find this option in the settings under ''[https://www.droidwiki.org/wiki/Entwickleroptionen Entwickleroptionen]'' called ''[https://www.droidwiki.org/USB-Debugging USB-Debugging]'. If the developer options are not displayed, you can unlock them by tapping Build Number seven times in About the Phone.<br />
<br />
Also enable the Stay On Watch feature to prevent the instrument from turning off the screen during test creation or execution.<br />
<br />
For security reasons, USB debugging must be allowed for each computer individually. When connecting the device to the PC via USB, you must agree to the connection on the device. If you haven't done this for your computer yet, but no corresponding dialog appears on the device, it may help to unplug and reconnect the device. This can happen especially if you have installed the ADB driver while the device was already connected via USB. If this doesn't help either, open the notifications by dragging them from the top of the screen. There you will find the USB connection and you can open the options. Select another type of connection; usually MTP or PTP should work.<br />
<br />
You can also test on an emulator. This emulator no longer needs to be prepared separately, as it is already designed for USB debugging. It is even possible to start an emulator at the beginning of the test.<br />
<br />
To check if a device you have connected to your computer can be used, open the [[#Verbindungseditor|Verbindungseditor]]. The device should be displayed there.<br />
<br />
=== Connection via WLAN ===<br />
It is possible to connect to Android-devices via Wireless LAN. To prepare and enable this, you have to connect initially via USB. Open a command window (terminal window) and enter:<br />
<nowiki>adb tcpip 5555</nowiki><br />
The device listens for a TCP/IP connection on port 5555. If you have several devices connected or emulators running, you have to specify which device you mean. Enter in this case:<br />
<nowiki>adb devices -l</nowiki><br />
to get a list of all devices, where the first column gives the device's ID.<br />
Then, enter:<br />
<nowiki>adb -s <DeviceID> tcpip 5555</nowiki><br />
with the device identification of the desired device. You can now disconnect the USB connection. Now you have to find out the IP address of your device. You can usually find it somewhere in the device's settings, for example in the Status or WLAN settings. Then type in:<br />
<nowiki>adb connect <IP-Adresse of Device></nowiki><br />
The device should now be connected via WLAN and can be used in the same way as with a USB connection. You can check this by entering adb devices -l again or open the connection dialog in expecco. In the list the device appears with its IP address and port. Remember that the WLAN connection no longer exists when the ADB server or the device is restarted.<br />
<br />
== Preparing an iOS-Device and App ==<br />
Control of iOS devices is only possible via a Mac. Please also read the section [[#Mac_OS|Installation under Mac OS]].<br />
<br />
Before you can control a mobile device with the Mobile Testing Plugin, you must allow debugging for iOS devices with iOS 8 or higher. Activate the option ''Enable UI Automation'' under the menu ''Developer'' in the device settings. If you cannot find the ''Developer'' entry in the settings, proceed as follows: Connect the device to the Mac via USB. If necessary, you must still agree to the connection on the device. Start Xcode and then select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device there. Then the entry ''Developer'' should appear in the settings on the device. You may have to exit the settings and restart.<br />
<br />
[[Datei:Alert.png | thumb | 270px | Alert unter iOS]]<br />
It is not possible to establish a connection to the device as long as it shows certain alerts. Such an alert may appear if FaceTime is activated by displaying a message about SMS charges (see screenshot). Be sure to configure the device so that it does not show such alerts when idle.<br />
<br />
=== expecco 2.11 and later ===<br />
You can test any apps that are executable or already installed on the device used. If the app is available as a development build, the UDID of the device must be stored in the app. In any case, the WebDriverAgent must be signed for the device. Please read the section [[#expecco_2.11|Preparation under Mac OS]].<br />
<br />
If you want to use the Home button in a test, you must activate AssistiveTouch on the device. You will find this option in the settings under ''General'' > ''Operating Help'' > ''AssistiveTouch''. Then place the menu in the middle of the upper edge of the screen. You can then record pressing the Home button with the corresponding menu entry in the recorder or use the ''Press Home Button'' block directly.<br />
<br />
=== expecco 2.10 ===<br />
The app you want to use must be available as a development build. The UDID of the device must also be stored in the app.<br />
<br />
=== Sign the development build ===<br />
A development build of an app is only allowed for a limited number of devices and cannot be started on other devices. However, it is possible to exchange the certificate and the usable devices in a development build.<br />
<br />
* Evaluation with demo app of eXept:<br />
:We will be happy to provide you with a demo app which is available as a development build and which we can sign for your device. Please send the UDID of your device to your eXept contact person. How to determine the UDID of your device is described in the following section.<br />
<br />
* Using your own app for your test device:<br />
:If you receive a development build (IPA file) from the app developers that is approved for your test device, you can use it directly. To do this, you must tell the developers the UDID of your device so they can enter it. '''You can use Xcode to read the UDID of a device'''. Start Xcode and select ''Devices'' from the menu bar at the top of the screen in the ''Window'' menu. A window opens in which a list of the connected devices is displayed. Select your device and search for the ''Identifier'' entry in Properties. The UDID is a 40-digit hexadecimal number.<br />
<br />
* Externally developed app for your test device:<br />
:You can also re-sign apps to make them run on other devices. However, this process is complicated and requires access to an Apple Developer account. A documentation on the procedure is currently in preparation.<br />
<br />
:For the evaluation we will gladly support you with the re-signing of your app..<br />
<!--<br />
Log in to the [https://developer.apple.com/ Apple-Webinterface]. Navigate to ''Certificates, IDs & Profiles''. If necessary, create a Developer Certificate and a Provisioning Profile for your device here and download both. If you don't have a Developer Account yet, create one here: https://developer.apple.com/enroll/. For this you have to register with an Apple-ID.<br />
<br />
# Find out Team ID (''Membership'' -> ''Team ID'')<br />
# Under ''Certificates, IDs & Profiles'' select development certificate (under ''+'' create, if not available) and download<br />
# Under ''App ID'' create Wildcard App ID, if not present. Note App ID (AppID = Prefix.ID)<br />
# Add device, find out UDID (or ''Identifier'') of the device (''Xcode'' -> ''Window'' (above in menu bar) -> ''Devices'')<br />
# Create commission profiles: ''iOS App Development'' -> Select ''AppID'' -> Select certificate -> Select device -> Create profile name -> Download provisioning profiles.<br />
# Import the downloaded certificate (''Downloads'' -> Certificate (.cer)<br />
# Copy SHA1 fingerprint. Right click on Certificate -> ''Information'', then scroll to the bottom of the page).<br />
# Create Entitlements.plist (''Open Terminal' -> Downloads/Mobile_Testing_Supplement/bin/gen-entitlements_plist 'Team-ID' 'App ID' Downloads/Mobile_Testing_Supplement/bin/re-sign-ipa <path to ipa (z.B. Downloads/expeccoMobileDemo.ipa)> \<br />
"<Zertifikat (SHA1-Fingerabdruck, z.B. 76 E8 4B E8 78 D5 D7 F9 2E 09 8B D7 E8 FB CE 30 0C F5 D0 EF)>" \<br />
<Path to Commission Profile (e.g. /Users/exept_test/Downloads/dut.mobileprovision)> \<br />
<Path for the result ipa (z.B. Downloads/expeccoMobileDemo_re-signed.ipa)> \<br />
[Pfad zur entitlements.plist] (z.B. /Users/exept_test/entitlements.plist)<br />
<br />
To re-sign, you can use the corresponding script from the Mobile Testing Supplement for Mac OS or any other tool (e.g. isign).<br />
--><br />
<br />
For more information about using iOS devices, see also the <br />
[http://appium.io/slate/en/master/?java#appium-on-real-ios-devices Dokumentation von Appium].<br />
<br />
=== Native iOS-Apps ===<br />
You can also use apps that are already natively present on the device. To do this, you must know their bundle ID and then enter it in the connection settings. Here is a small selection of common apps:<br />
{| style="text-align:left"<br />
! App<br />
!<br />
! Bundle-ID<br />
|-<br />
| App Store<br />
| <br />
| com.apple.AppStore<br />
|-<br />
| Calculator<br />
| <br />
| com.apple.calculator<br />
|-<br />
| Calendar<br />
| <br />
| com.apple.mobilecal<br />
|-<br />
| Camera<br />
| <br />
| com.apple.camera<br />
|-<br />
| Contacts<br />
| <br />
| com.apple.MobileAddressBook<br />
|-<br />
| iTunes Store<br />
| <br />
| com.apple.MobileStore<br />
|-<br />
| Mail<br />
| <br />
| com.apple.mobilemail<br />
|-<br />
| Maps<br />
| <br />
| com.apple.Maps<br />
|-<br />
| Messages<br />
| <br />
| com.apple.MobileSMS<br />
|-<br />
| Phone<br />
| <br />
| com.apple.mobilephone<br />
|-<br />
| Photos<br />
| <br />
| com.apple.mobileslideshow<br />
|-<br />
| Settings<br />
| <br />
| com.apple.Preferences<br />
|}<br />
<br />
You can find further Bundle-IDs [https://github.com/joeblau/apple-bundle-identifiers here].<br />
<br />
= Examples =<br />
In the demo test suites for expecco you will also find examples for tests with the Mobile Testing Plugin. To do this, select the option ''Example from file'' on the start screen and open the folder ''mobile''.<br />
<br />
==<span id="TestsuiteMobileTestingDemo"><!-- Referenced by m01_MobileTestingDemo.ets --></span> ''m01_MobileTestingDemo.ets'' ==<br />
The test suite contains two simple test plans: "''Simple CalculatorTest''" and "''Complex Calculator and Messaging Test''". Both tests use an Android emulator, which you must start before starting. The apps used in the test are part of the basic equipment of the emulator and therefore no longer need to be installed. Since the apps may differ under every Android version, it is important that your emulator runs under Android 6.0. In addition, the language must be set to English.<br />
<br />
; Simple CalculatorTest<br />
: This test connects to the calculator and enters the formula ''2+3''. The result of the calculator is compared with the expected value ''5''.<br />
<br />
; Complex Calculator and Messaging Test<br />
: This test connects to the calculator and then opens the message service. There it waits for an incoming message from the number ''15555215556'', in which a formula to be calculated is sent. The message is generated before via a socket at the emulator. When the message arrives, it is opened by the test and its contents are read. Then the calculator is opened again, the received formula is entered and the result is read. The test then switches back to the message service and sends the result as an answer.<br />
<br />
== ''m02_expeccoMobileDemo.ets'' und ''m03_expeccoMobileDemoIOS.ets'' ==<br />
These are part of the tutorial for the Mobile Testing Plugin. The included test case is incomplete and will be added during the tutorial. Please read the section [[#Tutorial|Tutorial]].<br />
<br />
= Tutorial =<br />
This tutorial describes the basic procedure for creating tests with the Mobile Testing Plugin. The basis for this is a supplied example consisting of a simple app and an expecco test suite.<br />
<br />
The ''expecco Mobile Demo'' app calculates and checks various everyday codes: the IBAN from European payment transactions, the international GTIN 13 product codes found in retail bar codes, and the serial numbers on euro banknotes.<br />
<br />
The test-suite contains test cases for individual functions of the app. Not all functions are covered yet, but will be added in the course of the tutorial.<br />
<br />
There are two versions of these Tutorials:<br />
*'''[[#Erste_Schritte_mit_Android|Erste Schritte mit Android]]'''<br />
*'''[[#Erste_Schritte_mit_iOS|Erste Schritte mit iOS]]'''<br />
<br />
The procedure is almost identical in both versions, only the connection configurations are created differently. The finished tests then differ essentially in the paths for addressing the elements used, since these are technology-dependent.<br />
<br />
==<span id="FirstStepsAndroid"><!-- Referenced by m02_expeccoMobileDemo.ets --></span> First steps with Android ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for the use of Android devices under Windows.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m02_expeccoMobileDemo.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. This test-suite already contains a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
In the test suite the package of the demo app is included as an attachment (''expeccoMobileDemo-debug.apk''). Using the provided module ''Export Demo App'' you can export the file to any location on your computer. Select the device (1) and click on the green play button (2) to execute the device (fig. 2). The block opens a file dialog in which you specify where the package should be saved.<br />
<br />
[[Datei:MobileTestingExportApp.png | frame | left | Abb. 2: App exportieren]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. To do this, connect a device to your computer via USB or start an emulator.<br />
<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 3: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 3) to open the connection dialog.<br />
<br />
You will see a list of all connected Android devices (1) (Fig. 3). If your device does not appear in the list, make sure it is turned on and connected via USB. Otherwise read the section [[#Prepare_Android_Device|Prepare Android Device]]<br />
<br />
[[Datei:MobileTestingGerätAuswählen.png | frame | left | Abb. 4: Gerät im Verbindungsdialog auswählen]]<br />
<br clear="all"><br />
Once you have found your device in the list, select it and click ''Next'' (2).<br />
<br />
Next, specify which app you want to use (Fig. 5). You can choose if you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you will get a list of all packages installed on the device (1), which are divided into system packages and foreign packages (2), as well as their activities (3). You can then simply select these in the respective fields.<br />
<br />
[[Datei:MobileTestingAppAuswählen.png | frame | left | Abb. 5: Auf dem Gerät installierte App angeben]]<br />
<br clear="all"><br />
For this tutorial the app you just exported from the test-suite should be installed. Select ''Install App'' and enter the appropriate path in App (1) (Fig. 6). You can use the button on the left (2) to open a file dialog where you can navigate to the file to enter it. The package (3) and the activity (4) of the app will be entered automatically. If the app has multiple activities, you can select the one you want. Now click on ''Next'' (5).<br />
<br />
[[Datei:MobileTestingAppInstallieren.png | frame | left | Abb. 6: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
On the last page you can see an overview of all previous data (1) (Fig. 7). Below, you can enter a name for the connection under which it will be displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). Appium is the interface, via which the connected devices are controlled. For this tutorial expecco manages the instances of the Appium server. Enter the local default address ''<nowiki>http://localhost:4723/wd/hub</nowiki>''. This is always the lowest entry in the proposal list. In addition the option ''Start if necessary'' is activated (4). expecco then checks if an Appium server is already running at the address and starts and ends it automatically if necessary. If the port ''4723'' is already occupied or if you want to use several connections at the same time, use a different port at this point. It is common to use the odd port numbers above ''4723'', i.e. ''4725'', ''4727'' and so on. Of course you can also use remote servers, but the automatic start and stop of a server can only be done locally by expecco.<br />
<br />
[[Datei:MobileTestingServerkonfiguration.png | frame | left | Abb. 7: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 8). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Start server and connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 8: Einstellungen speichern]]<br />
<br clear="all"><br />
It may take a while to establish the connection. Wait until the connection is established and displayed in the GUI browser. You will see that the app is started on the device. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 9). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 9: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 10). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 10: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered here. Since the same name was used for the connection in the test run, the settings were overwritten (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1), then press the record button (2) to start recording (Fig. 11).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 11: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 12). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1.png | frame | left | Abb. 12: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 13). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2.png | frame | left | Abb. 13: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 14). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''text'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3.png | frame | left | Abb. 14: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 15). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''HOME'' button on the top right of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 15: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting 'Close connection' from the context menu.<br />
<br />
Switch back to the Testsuite tab. The new module was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#Customizing XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Select the new device and click on the Save icon in the attachment until the delayed menu opens (Fig. 16). Select 'Save device settings' here. It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 16: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify blocks that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore, copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 17).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK.png | frame | left | Abb. 17: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 18). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 18: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
==<span id="FirstStepsIOS"><!-- Referenced by m03_expeccoMobileDemoIOS.ets --></span> Erste Schritte mit iOS ==<br />
It is assumed that you have already read the chapter [[#Installation_und_Aufbau|Installation und Aufbau]] and completed the necessary preparations for using iOS devices under Mac OS. Connect the device you want to use to the Mac. Download the iOS version of the [http://download.exept.de/transfer/h-expecco-2.11.0-pre/expeccoMobileDemo.ipa expeccoMobileDemo app] to your Mac. Since the app is a debug build, you still need to sign it for your device (see [[#iOS-Ger.C3.A4t_und_App_prepare|iOS_device and Prepare App]]). Now start an Appium server on the Mac.<br />
<br />
=== Step 1: Run Demo ===<br />
Start expecco and open the test-suite ''m03_expeccoMobileDemoIOS.ets'' via the button ''Example from file'' (fig. 1). As of expecco 2.11 this is located in the subfolder ''mobile''. Otherwise download the test-suite [http://download.exept.de/transfer/h-expecco-2.10.0/m03_expeccoMobileDemoIOS.ets m03_expeccoMobileDemoIOS.ets] to the computer where your expecco installation is located and open it. In this test-suite there is already a ready-made test plan with some test cases for this app.<br />
<br />
[[Datei:MobileTestingIOSBeispielÖffnen.png | frame | left | Abb. 1: Beispiel-Testsuite öffnen]]<br />
<br clear="all"><br />
Before we get into the rest of the test-suite, first configure the connection and which device you want to use. Now open the GUI browser (1) and select the entry ''Mobile Testing'' (3) under ''Connect'' (2) (Fig. 2) to open the connection dialog.<br />
[[Datei:MobileTestingVerbinden.png | frame | left | Abb. 2: Verbindungseditor öffnen]]<br />
<br clear="all"><br />
<br />
Here you can enter an iOS device only by hand. Select ''Enter iOS device'' (Fig. 3). The name and iOS version of the device can be found in its properties. To find out the device ID of the device, open the Devices (Command-Shift-2) window in Xcode on the Mac. All connected devices and the available simulators are displayed there. Here you can also see the device ID (udid) of your device and which apps have been installed. After you have entered the device in the connection editor, select it in the list and click Next.<br />
<br />
[[Datei:MobileTestingIOSGerät.png | frame | left | Abb. 3: Hinzufügen eines iOS-Geräts]]<br />
<br clear="all"><br />
<br />
Next, specify which app you want to use. You can choose whether you want to start an app that is already installed on the device (''App on the device'') or if you want to install and start an app (''Install app''). In case you want to use an already installed app, you have to specify its bundle ID. You will also find this in the Devices window of Xcode. For the demo app it is ''de.exept.expeccoMobileDemo''.<br />
<br />
For this tutorial the demo app has to be installed first. Select ''Install App'' and enter the path to the file on your Mac (fig. 4). If you are using expecco 2.11, you can also specify the Team-ID on this page, which specifies which certificate should be used for iOS connections. If you have already specified an ID in [[#Configuration_of_Plugins|Plugin Settings]], it will be used. It will be grayed out unless you specify another value. Now click on ''Next''.<br />
<br />
[[Datei:MobileTestingIOSAppInstallieren.png | frame | left | Abb. 4: App angeben, die auf dem Gerät installiert werden soll]]<br />
<br clear="all"><br />
<br />
On the last page you can see an overview of all previous data (1) (Fig. 5). Below the Capabilities list, you can enter a name for the connection under which it is displayed in the GUI browser (2). In addition, a connection can be identified by this name and used in blocks; the name must therefore be unique. If you do not specify a name, one is generated generically. Enter ''expeccoMobileDemo'' as the name. Enter the address for the Appium server in the field below (3). If you have started the Appium server with default settings, you only have to replace ''localhost'' in the default address (lowest entry of the suggestion list) with the IP address of the Mac (in the picture ''172.23.1.49''). To make sure which port the Appium server is listening on, see its output. At the beginning there is the line<br />
<nowiki>info: Appium REST http interface listener started on 0.0.0.0:4723</nowiki><br />
If the default port ''4723'' does not appear at the end, change this value accordingly in the configuration.<br />
<br />
If the option ''Start on demand'' (4) is activated, expecco checks if an Appium server is already running at the address and starts and stops it automatically if necessary. However, this is only possible for local server addresses, so deactivate this option.<br />
<br />
[[Datei:MobileTestingServerkonfigurationIOS.png | frame | left | Abb. 5: Verbindungsnamen und Appium-Server konfigurieren]]<br />
<br clear="all"><br />
<br />
Now click on ''Save'' (5) to save the settings for the test execution. Settings can be saved as an attachment to an execution definition or to an external file (Fig. 6). If you have several projects open at the same time, you can select the project in which the attachment is to be created from the list. Click on ''Save'' in the ''Save settings in attachment'' area and enter ''expeccoMobileDemo'' as the name. Now click on ''Connect'' (6) to establish a connection with the specified configuration.<br />
<br />
[[Datei:MobileTestingEinstellungenSpeichern.png | frame | left | Abb. 6: Einstellungen speichern]]<br />
<br clear="all"><br />
<br />
It may take a while to establish the connection. If you have entered the correct server address, you should see the connection attempt in the Appium server output. The app should be started on your iOS device. If nothing happens on the device, either the device or the app may not be found. If Appium tries to start the app and this fails, the app is probably signed incorrectly. In this case, uninstall the app so that it can be reinstalled with a new signature.<br />
<br />
Wait until the connection is established and displayed in the GUI browser. Now you know that the configuration works. The saved settings should now be used for the test, which then establishes the same connection. Select the connection in the GUI browser, right-click and select 'Close Connection' from the context menu to avoid any conflict. Then switch back to the test-suite tab.<br />
<br />
In the test-suite, the settings were created as an appendix ''expeccoMobileDemo'' (Fig 7). Select the ''Connect'' block (1) and switch to the ''Network'' view on the right (2). Drag and drop the settings into the network of the block (3). Connect the output pin ''pathName'' with the input pin ''stringOrFilename[1]'' of the block ''Connect from File'' (4). Confirm the changes with ''Apply'' (5). This block will establish the connection to the app at the beginning of the test.<br />
<br />
[[Datei:MobileTestingConnectblock.png | frame | left | Abb. 7: Verbindungsbaustein editieren]]<br />
<br clear="all"><br />
<br />
Now switch to the test plan ''Demo Test'' (1) (Fig. 8). This test plan already contains some finished test cases. Before and after the execution (2) one block is also entered: The just edited block ''Connect'' for the setup and the block ''Disconnect'' for the disconnection. By entering the two blocks at this point, the connection is terminated, especially if the test is aborted prematurely, e.g. because one of the test cases fails.<br />
<br />
[[Datei:MobileTestingTestplan.png | frame | left | Abb. 8: Testplanausführung]]<br />
<br clear="all"><br />
Now you can start the test plan ''Demo Test'' by clicking on the green Play button (3). The test plan should run without errors.<br />
<br />
=== Step 2: Creating a Block with the Recorder ===<br />
With the help of the integrated recorder, you can easily record execution sequences and store them in a block. This requires a connection to a test device, which is used to create the test.<br />
<br />
To establish a connection, switch back to the GUI browser. The connection that you created previously is still entered in this browser. Since the same name was used for the connection in the test run, the settings were overwritten with it (in our case, the settings were identical anyway). The connection is currently not active, since it was terminated at the end of the execution. However, the settings are still entered there. To reestablish the connection with this configuration, select it, right-click it, and then ''Connect''.<br />
<br />
Wait until the connection is established (1) and then press the record button (2) to start recording (Fig. 9).<br />
<br />
[[Datei:MobileTestingRecorderStarten.png | frame | left | Abb. 9: Recorder starten]]<br />
<br clear="all"><br />
A window opens with the Mobile Testing Recorder (Fig. 10). This shows a screenshot of the connected device. This screen allows you to control the device remotely. Every action you perform is recorded in the background.<br />
<br />
In the upper menu bar you can select the tool (1) with which you want to enter an action. The Auto tool is selected by default. You can use it to record certain actions by making gestures on the display with the mouse pointer. For example, if you left-click for a long time, this corresponds to a long tap on the element at this point. Instead of specifying the desired action with the corresponding gesture, you can also select it manually.<br />
<br />
A new test for the recognition of correct GTIN-13 codes should now be recorded. First click briefly on the button ''GTIN-13 (EAN-13)'' (2) of the app in the display to trigger a corresponding click on the device. During the execution of this action, the frame of the recorder will briefly turn red. If the recorder does not display the current view of the app afterwards, click on the update icon (3) in the recorder.<br />
<br />
[[Datei:MobileTestingRecorder1iOS.png | frame | left | Abb. 10: Über Recorder zur GTIN-13-Activity wechseln]]<br />
<br clear="all"><br />
Then enter a correct GTIN-13 in the input field of the new page. To do this, right-click on the input field (1) and select the action ''Set text'' (2) in the context menu (Fig. 11). Enter any valid article number in GTIN-13 format, e.g. ''4006381333986'' (3). This text is now set in the app.<br />
<br />
[[Datei:MobileTestingRecorder2iOS.png | frame | left | Abb. 11: GTIN-13-Code über Recorder eingeben]]<br />
<br clear="all"><br />
Now click on ''Verify'' (1) (Fig. 12). The app now displays ''OK'' (2) as the result. The test should determine whether this result is actually displayed. After a right click you can select the action ''Assure attribute'' (3) in the context menu. In the dialog that opens, select the property ''value'' (4) and confirm with ''OK'' (5). This time, no action is triggered on the device, but only a block is recorded that fails if the result deviates from the expected value ''OK''.<br />
<br />
[[Datei:MobileTestingRecorder3iOS.png | frame | left | Abb. 12: Antwort der App über Recorder auslesen]]<br />
<br clear="all"><br />
Now close the recorder. In the ''workspace'' of the GUI browser you can see that a block has been created for each of the recorded actions (Fig. 13). You can now test whether the recorded action can be played back. To do this, you must first return the app on your device to its initial state by using the ''Home'' button on the top left of the device. Then click in expecco on the green Play button (1). If everything turns green, the execution was successful. Now create a new block in the test-suite by clicking on the block symbol (2) in the upper right corner. Give it the name ''GTIN_Verify_OK'' (3) and confirm (4).<br />
<br />
[[Datei:MobileTestingArbeitsbereich.png | frame | left | Abb. 13: Neuen Baustein aus Arbeitsbereich exportieren]]<br />
<br clear="all"><br />
Now close the connection by selecting the connection, right-clicking and selecting 'Close connection' from the context menu.<br />
<br />
Switch back to the test-suite tab. The new block was created there. Again select the test plan ''Demo-Test'' and add the recorded test case ''GTIN_Verify_OK'' by drag-and-drop at the end of the test plan. Apply the change and restart. The test plan should run again without errors.<br />
<br />
=== Step 3: Customizing XPath Using the GUI Browser ===<br />
Your new device may not work on other devices. The elements used are addressed via an XPath and this cannot be correct on other devices. See the [[#XPath_Customizing_Using_the_GUI_Browser_To_Customize_XPath Using the GUI Browser]] section for more information. If you have another device available, you can now try to generalize the paths in your created devices. You can also skip this step.<br />
<br />
If you find it difficult to find shortened paths, follow the paths of the existing blocks. Start the test again. If the test now fails, check the paths again in the GUI browser.<br />
To run the test on a second device, open in the menu ''Extensions'' > ''Mobile Testing'' > ''Create connection settings''. You will get a dialog similar to the connection dialog. However, you can only create and save settings but not establish a connection. However, you have the option to save individual aspects of the settings, such as only the device. Enter the new device and select it. Click longer on the symbol for saving in the attachment until the delayed menu opens and select ''Save device settings'' here (Fig. 14). It is best to name the attachment after the device. You can then close the dialog again.<br />
<br />
[[Datei:MobileTestingGerätSpeichern.png | frame | left | Abb. 14: Einstellungen für ein Gerät speichern]]<br />
<br clear="all"><br />
Select the ''Connect'' block and drag the settings for the new device into its network. Now connect its output pin ''pathName'' with the input pin ''stringOrFilename[2]'' of the block ''Connect from File''. The block Connect from File reads the information at the input pins from top to bottom, multiple properties are replaced. In this case, the settings for the device used are replaced, while the other settings remain the same. If you have chosen the paths skilfully, the test will now also run successfully on the other device.<br />
<br />
=== Step 4: Create another block ===<br />
If the same procedures are repeated in the test, you can reuse or modify modules that have already been created for this purpose. The block created in step 2 checks the recognition of correct GTIN 13 codes. A test is still missing which, conversely, checks the detection of a wrong GTIN-13 code. The structure of the two tests is identical, they only differ in their parameters. Therefore copy the block ''GTIN_Verify_OK'' and rename the copy to ''GTIN_Verify_NOT_OK''. Change the input of the GTIN-13 to a wrong code, for example by changing the last digit (''4006381333987'') and set the check value of the output to ''NOT OK'' (Fig. 15).<br />
<br />
[[Datei:MobileTestingGTIN_Verify_NOT_OK_iOS.png | frame | left | Abb. 15: Baustein editieren]]<br />
<br clear="all"><br />
Add this new test to the Test Plan Demo Test as well and place it at the end. Run the test plan, but don't forget to disconnect in the GUI browser first.<br />
<br />
The new test will fail because the device you added does not return to the start page of the app, but the tests start from there. This is already considered in the other blocks; they always execute the block ''Back to main menu'' at the end. You can see this by selecting one of the other blocks, e.g. ''GTIN_Calculate'', and switching to its schematic view. There the block ''Back to main menu'' is displayed in the field ''After execution'' (Fig. 16). As with the corresponding field in the test plan, this block is always executed at the end, regardless of whether the test is successful or aborted. Now add this entry to your blocks ''GTIN_Verify_OK'' and ''GTIN_Verify_NOT_OK''. Select the block and drag the block ''Back to main menu'' in the schema view to the input field ''After execution''. Now you can start the test plan and all tests should be executed again without any problems.<br />
<br />
[[Datei:AppiumDemo Nach Ausführung.png | frame | left | Abb. 16: Nach-Ausführungs-Baustein setzen]]<br />
<br clear="all"><br />
<br />
=== Step 5: Complete Test ===<br />
For the Activity IBAN all answer possibilities of the app are already covered with test cases. In the GTIN-13-Activity a correct and a faulty code are tested and a check digit is calculated, but the behaviour of the app in case of input of wrong length is not tested yet (With Verify '''Input must be exactly 13 digits''. and ''...12 digits''. for Calculate). The activity for checking the serial numbers of euro banknotes is not yet tested. As with the IBAN, three cases can occur here: a correct serial number was entered (answer: ''OK''), an incorrect serial number was entered (answer: ''NOT OK'') or the specification does not correspond to the format (answer: ''A serial number consists of 12 characters with the first one or two being capital letters (A-Z).''). You can now extend the test coverage by creating test cases. You can create the blocks for this with the recorder as in step 2 and generalize the XPaths if necessary. If you are familiar with the basic handling of expecco, you can of course also create blocks without recorder by manually assembling them from existing blocks of the library. You can also combine both approaches as you wish.<br />
<br />
Note that the test cases presented here only check individual entries. If you write test cases for your own apps, you will probably want to test more closely by entering more different values, including edge cases.<br />
<br />
= Dialoge des Mobile Testing Plugins =<br />
== Verbindungseditor ==<br />
Mithilfe des Verbindungseditors können Sie schnell Verbindungen definieren, ändern oder aufbauen. Je nach Aufgabe weist der Dialog kleine Unterschiede auf und wird unterschiedlich geöffnet:<br />
*Wenn Sie eine Verbindung aufbauen wollen, erreichen Sie den Dialog im GUI-Browser, indem Sie auf ''Verbinden'' klicken und dann ''Mobile Testing'' auswählen.<br />
*Um eine bestehende Verbindung im GUI-Browser zu ändern oder zu kopieren, wählen Sie diese aus, machen einen Rechtsklick und wählen im Kontextmenü entsprechend ''Verbindung bearbeiten'' oder ''Verbindung kopieren'' aus.<br />
*Wollen Sie Verbindungseinstellungen nicht für den GUI-Browser sondern zur Verwendung in einem Test erstellen, wählen Sie im Menü des Mobile Testing Plugins den Punkt ''Verbindungseinstellungen erstellen...''. Darüber können nur die Einstellungen für eine Verbindung erstellt werden, ohne dass eine Verbindung im GUI-Browser angelegt wird.<br />
<br />
Das Menü des Verbindungseditors weist verschiedenen Schaltflächen auf, von denen manche nur beim Erstellen von Verbindungseinstellungen sichtbar sind:<br />
[[Datei:MobileTestingVerbindungseditorMenu.png]]<br />
#''Einstellungen löschen'': Setzt alle Einträge zurück. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Einstellungen aus Datei laden'': Erlaubt das Öffnen einer gespeicherten Einstellungsdatei (*.csf). Deren Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen aus Anhang laden'': Erlaubt das Öffnen eines Anhangs mit Verbindungseinstellungen aus einem geöffneten Projekt. Diese Einstellungen werden in den Dialog übernommen. Bereits getätigte Eingaben ohne Konflikt bleiben dabei erhalten.<br />
#''Einstellungen in Datei speichern'' und<br />
#''Einstellungen in Anhang speichern'': Hier können Sie die eingetragenen Einstellungen in eine Datei (*.csf) speichern oder als Anhang in einem geöffneten Projekt anlegen. Beide Optionen besitzen ein verzögertes Menü, in dem Sie auswählen können, nur einen bestimmten Teil der Einstellungen zu speichern. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Erweiterte Ansicht'': Damit können Sie in die erweiterte Ansicht wechseln, um zusätzliche Einstellungen vorzunehmen. Lesen Sie dazu mehr am Ende des Kapitels. (Nur beim Erstellen von Einstellungen sichtbar.)<br />
#''Hilfe'': An der rechten Seite wird ein Hilfetext zum jeweiligen Schritt ein- oder ausgeblendet.<br />
<br />
<br />
Der Dialog ist in drei Schritte unterteilt. Im ersten Schritt wählen Sie das Gerät, das Sie verwenden möchten, im zweiten Schritt wählen Sie aus, welche App verwendet werden soll und im letzten Schritt erfolgen die Einstellungen zum Appium-Server.<br />
<br />
===<span id="AppiumConnectionEditorStep1"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 1: Gerät auswählen===<br />
Im oberen Teil erhalten Sie eine Liste aller angeschlossenen Appium-Geräte, die erkannt werden. Mit der Checkbox darunter können Sie die Geräte ausblenden, die zwar erkannt werden, aber nicht bereit sind. Falls Sie ein Gerät eintragen wollen, das nicht angeschlossen ist, können Sie dies mit dem entsprechenden Knopf ''Android-Gerät eingeben'' bzw. ''iOS-Gerät eingeben'' anlegen. Dazu müssen Sie jedoch die benötigten Eigenschaften Ihres Geräts kennen. Das Gerät wird dann in einer zweiten Geräteliste angelegt und kann dort ausgewählt werden. Wenn keine Liste mit angeschlossenen Elementen angezeigt werden kann, werden stattdessen verschiedene Meldungen angezeigt:<br />
*Keine Geräte gefunden<br />
*:expecco konnte kein Android-Geräte finden.<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*Keine verfügbaren Geräte gefunden<br />
*:expecco konnte keine verfügbaren Android-Geräte finden. Es wurden aber nicht verfügbare gefunden, z.B. mit dem Status "unauthorized".<br />
*:Um eine Verbindung zu einem Gerät automatisch zu konfigurieren, stellen Sie sicher, dass es<br />
*:*angeschlossen ist<br />
*:*eingeschaltet ist<br />
*:*einen passenden adb-Treiber installiert hat<br />
*:*für Debugging freigeschaltet ist (siehe unten).<br />
*:Um nicht verfügbare Geräte anzuzeigen, aktivieren Sie unten diese Option.<br />
*Verbindung verloren<br />
*:expecco hat die Verbindung zum adb-Server verloren. Versuchen Sie die Verbindung wieder herzustellen, indem Sie auf den Button klicken.<br />
*Verbindung fehlgeschlagen<br />
*:expecco konnte sich nicht mit dem adb-Server verbinden. Möglicherweise läuft er nicht oder der angegebene Pfad stimmt nicht.<br />
*:Überprüfen Sie die adb-Konfiguration in den Einstellungen und versuchen Sie den adb-Server zu starten und eine Verbindung herzustellen indem Sie auf den Knopf klicken.<br />
*Verbinden ...<br />
*:expecco verbindet sich mit dem adb-Server. Dies kann einige Sekunden dauern.<br />
*adb-Server starten ...<br />
*:expecco startet den adb-Server. Dies kann einige Sekunden dauern.<br />
<br />
<!--Bei ''Automatisierung durch'' können Sie angeben, welche Automation-Engine verwendet werden soll. Lassen Sie die Einstellung auf ''(Default)'' wird die entsprechende Capability gar nicht gesetzt. Ansonsten stehen Appium, Selendroid und ab expecco 2.11 XCUITest zur Verfügung. In der Regel wird Selendroid nur für Android-Geräte vor Version 4.1 gebraucht.-->Mit ''Weiter'' gelangen Sie zum nächsten Schritt. Wenn Sie Einstellungen für den GUI-Browser eingeben, ist das erst möglich, wenn ein Gerät ausgewählt wurde.<br />
<br />
<span id="UnlockingDeveloperOptions">Anmerkung zum Freischalten</span>: In jüngeren Android Versionen werden die Entwickleroptionen zunächst nicht mehr in den Einstellungen angeboten. Falls ihr Android Gerät in den Einstellungen keinen Eintrag zu "''Entwickleroptionen''" zeigt, wählen Sie zunächst den Eintrag "''Telefoninfo''", dann "''SoftwareVersionsInfo''" und klicken darin mehrfach auf den Eintrag "''BuildVersion''".<br />
<br />
===<span id="AppiumConnectionEditorStep2"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 2: App auswählen===<br />
Hier können Sie Angaben zur App machen, die getestet werden soll. Dabei können Sie entscheiden, ob Sie eine App verwenden wollen, die bereits auf dem Gerät installiert ist, oder ob für den Test eine App installiert werden soll. Wählen Sie oben den entsprechenden Reiter aus. Je nachdem, ob Sie im vorigen Schritt ein Android- oder ein iOS-Gerät ausgewählt haben, ändert sich die erforderte Eingabe.<br />
<br />
*'''Android'''<br />
**''App auf dem Gerät''<br />
**:Wenn Sie im ersten Schritt ein angeschlossenes Gerät ausgewählt haben, werden die Pakete aller installierten Apps automatisch abgerufen und Sie können die Auswahl aus den Drop-down-Listen treffen. Die installierten Apps sind in Fremdpakete und Systempakete unterteilt; wählen Sie die entsprechende Paketliste aus. Diese Auswahl gehört nicht zu den Einstellungen, sondern stellt nur die entsprechende Paketliste zur Verfügung. Sie können den Filter benutzen, um die Liste weiter einzuschränken und dann das gewünschte Paket auswählen. Die Activities des ausgwählten Pakets werden ebenfalls automatisch abgerufen und als Drop-down-Liste zur Verfügung gestellt. Wählen Sie die Activity aus, die gestartet werden soll. In der Regel wird automatisch eine Activity aus der Liste eingetragen. Falls Sie kein verbundenes Gerät verwenden, müssen Sie die Eingabe des Pakets und der Activity von Hand vornehmen.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Benutzen Sie einen lokalen Appium-Server, können Sie den rechten Butten benutzen, um zu der Installationsdatei der App zu navigieren und diesen Pfad einzutragen. Wenn möglich werden dabei auch das entsprechende Paket und die Activity in den Feldern darunter eingetragen. Diese Angabe ist aber nicht notwendig.<br />
<br />
*'''iOS'''<br />
**''App auf dem Gerät''<br />
**:Geben Sie die Bundle-ID einer installierten App an. Sie können die IDs der installierten Apps bspw. mithilfe von Xcode erfahren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Es öffnet sich ein Fenster, in dem eine Liste der angeschlossenen Geräte angezeigt wird. Wenn Sie Ihr Gerät auswählen, sehen Sie in der Übersicht eine Auflistung der von Ihnen installierten Apps.<br />
**''App installieren''<br />
**:Geben Sie bei ''App'' den Pfad zu einer App an. Der Pfad muss für den Appium-Server gültig sein, der verwendet wird. Sie können auch eine URL angeben. Zu den Vorraussetzungen an Apps für reale Geräte lesen Sie bitte den Abschnitt [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Geräte und App vorbereiten]].<br />
<br />
Im unteren Teil können Sie festlegen, ob die App beim Verbindungsabbau zurückgesetzt bzw. deinstalliert werden soll, und ob sie initial zurückgesetzt werden soll. Auch hier wird die entsprechende Capability gar nicht gesetzt, wenn Sie ''(Default)'' auswählen. Mit ''Weiter'' gelangen Sie zum nächsten Schritt.<br />
<br />
===<span id="AppiumConnectionEditorStep3"><!-- Referenced by AppiumConnectionEditor in Mobile Testing Plugin --></span>Schritt 3: Servereinstellungen===<br />
Im letzten Schritt befindet sich zunächst im oberen Teil eine Liste aller Capabilities, die sich aus Ihren Angaben der vorigen Schritte ergeben. Wenn Sie sich mit Appium auskennen und noch zusätzliche Capabilities setzen möchten, die der Verbindungseditor nicht abdeckt, können Sie durch Klicken auf ''Bearbeiten'' in die erweiterte Ansicht gelangen. Lesen Sie dazu den Abschnitt weiter unten.<br />
<br />
Wenn Sie Einstellungen für den GUI-Browser eingeben, können Sie den ''Verbindungsnamen'' eintragen, mit dem die Verbindung angezeigt wird. Dies ist auch der Name unter dem Bausteine diese Verbindung verwenden können, wenn sie aufgebaut ist. Wenn Sie das Feld frei lassen, wird ein Name generiert. Um die Adresse für den Appium-Server anzugeben, erhalten Sie die lokale Standard-Adresse und bereits verwendete Adressen zur Auswahl. Wenn Sie den Haken für ''Bei Bedarf starten'' setzen, versucht expecco beim Verbinden einen Appium-Server an der angegebenen Adresse zu starten, wenn dort noch keiner läuft. Dieser Server wird dann beim Beenden der Verbindung ebenfalls heruntergefahren. Dies funktioniert nur für lokale Adressen. Achten Sie darauf, nur Portnummern zu verwenden, die auch frei sind. Verwenden Sie am besten nur ungerade Portnummern ab dem Standardport 4723. Beim Verbindungsaufbau wird ebenfalls die folgende Portnummer verwendet, wodurch es sonst zu Konflikten kommen könnte.<br />
<br />
Je nachdem, wie Sie den Dialog geöffnet haben, gibt es nun verschiedene Schaltflächen um ihn abzuschließen. In jedem Fall haben Sie die Option zu speichern. Dabei öffnet sich ein Dialog, indem Sie entweder ein geöffnet Projekt auswählen können, um die Einstellungen dort als Anhang zu speichern, oder auswählen es in einer Datei zu speichern, die Sie anschließend angeben können. Durch das Speichern wird der Dialog nicht beendet, wodurch Sie anschließend noch eine andere Option auswählen könnten.<br />
<br />
Wenn Sie den Editor zum Verbindungsaufbau geöffnet haben, können Sie abschließend auf ''Verbinden'' oder ''Server starten und verbinden'' klicken, je nachdem, ob der Haken für den Serverstart gesetzt ist. Für das Ändern oder Kopieren einer Verbindung im GUI-Brower heißt diese Option ''Übernehmen'', da in diesem Fall nur der Verbindungseintrag geändert bzw. neu angelegt wird, der Verbindungsaufbau aber nicht gestartet wird. Das können Sie bei Bedarf anschließend über das Kontextmenü tun. Falls Sie Capabilities einer bestehenden Verbindung geändert haben, fordert Sie anschließend ein Dialog auf zu entscheiden, ob diese Änderungen direkt übernommen werden sollen, indem die Verbindung abgebaut und mit den neuen Verbindungen aufgebaut wird, oder nicht. In diesem Fall werden die Änderungen erst wirksam, nachdem Sie die Verbindung neu aufbauen.<br />
<br />
Zur Verwendung des Verbindungseditors lesen Sie auch den entsprechenden Abschnitt im jeweiligen Tutorial in Schritt 1 (Android: [[#Schritt_1:_Demo_ausf.C3.BChren|Demo ausführen]], iOS: [[#Schritt_1:_Demo_ausf.C3.BChren_2|Demo ausführen]]).<br />
<br />
===Erweiterte Ansicht===<br />
Die erweiterte Ansicht des Verbindungseditors erhalten Sie entweder durch Klicken auf ''Bearbeiten'' im dritten Schritt oder jederzeit über den entsprechenden Menüeintrag, wenn Sie den Editor über das Plugin-Menü gestartet haben. In dieser Ansicht erhalten Sie eine Liste aller eingestellten Appium-Capabilities. Zu dieser können Sie weitere hinzufügen, Einträge ändern oder entfernen. Um eine Capability hinzuzufügen, wählen Sie diese aus der Drop-down-Liste des Eingabefelds aus. In dieser befinden sich alle bekannten Capabilities sortiert in die Kategorien ''Common'', ''Android'' und ''iOS''. Haben Sie eine Capability ausgewählt, wird ein kurzer Informationstext dazu angezeigt. Sie können in das Feld auch von Hand eine Capability eingeben. Klicken Sie dann auf ''Hinzufügen'', um die Capabilitiy in die Liste einzutragen. Dort können Sie in der rechten Spalte den Wert setzen. Um einen Entrag zu löschen, wählen Sie diesen aus und klicken Sie auf ''Entfernen''. Mit ''Zurück'' verlassen Sie die erweiterte Ansicht.<br />
<br />
[[Datei:MobileTestingErweiterteAnsicht.png]]<br />
<br />
== Laufende Appium-Server ==<br />
Im Menü des Mobile Testing Plugins finden Sie den Eintrag ''Appium-Server...''. Mit diesem öffnen Sie ein Fenster mit einer Übersicht aller Appium-Server, die von expecco gestartet wurden und auf welchem Port diese laufen. Durch Klicken auf das Icon in der Spalte ''Log anzeigen'' können Sie das Logfile des entsprechenden Servers anschauen. Dieses wird beim Beenden des Servers wieder gelöscht. Mit den icons in der Spalte ''Beenden'' kann der entsprechenden Server beendet werden. Allerdings wird dies verhindert, wenn expecco über diesen Server noch eine offene Verbindung hat.<br />
<br />
Außerdem können Sie hier auch Server starten. Verwenden Sie die Eingabefelder zur Konfiguration der Serveradresse. Sie können die Felder auch frei lassen, um die Standardwerte zu verwenden. Bitte beachten Sie, dass Server nur lokal gestartet werden können und der gewählte Port nicht belegt sein darf. Typischerweise werden die ungeraden Portnummern ab 4723 verwendet. Die folgende Portnummer wird beim Verbinden mit einem Gerät ebenfalls benötigt, wodurch es mit den geraden Nummern zu Konflikten kommen könnte.<br />
<br />
[[Datei:MobileTestingAppiumServer.png]]<br />
<br />
Im Menü des Mobile Testing Plugins finden Sie auch den Eintrag ''Alle Verbindungen und Server beenden''. Dies ist für den Fall gedacht, dass Verbindungen oder Server auf andere Weise nicht beendet werden können. Beenden Sie Verbindungen wenn möglich immer im GUI-Browser oder durch Ausführen eines entsprechenden Bausteins. Server, die Sie in der Server-Übersicht gestartet haben, beenden Sie dort; Server, die mit einer Verbindung gestartet wurden, werden automatisch mit dieser beendet.<br />
<br />
Beachten Sie, dass in der Übersicht nur Server aufgelistet sind, die von expecco gestartet und verwaltet werden. Mögliche andere Appium-Server, die auf andere Art gestartet wurden, werden nicht erkannt.<br />
<br />
== Recorder ==<br />
Besteht im GUI-Browser eine Verbindung zu einem Gerät, kann der integrierte Recorder verwendet werden, um mit diesem Gerät einen Testabschnitt aufzunehmen. Sie starten den Recorder, indem Sie im GUI-Browser die entsprechende Verbindung auswählen und dann auf den Aufnahme-Knopf klicken. Für den Recorder öffnet sich ein neues Fenster. Die aufgezeichneten Aktionen werden im Arbeitsbereich des GUI-Browsers angelegt. Daher ist es möglich, das Aufgenommene parallel zu editieren.<br />
<br />
[[Datei:MobileTestingRecorder.png|caption|]]<br />
<br />
;Komponenten des Recorderfensters<br />
#'''Aktualisieren''': Holt das aktuelle Bild und den aktuellen Elementbaum vom Gerät. Dies wird nötig, wenn das Gerät zur Ausführung einer Aktion länger braucht oder sich etwas ohne das Anstoßen durch den Recorder ändert.<br />
#'''Follow-Mouse''': Das Element unter dem Mauszeiger wird im GUI-Browser ausgewählt.<br />
#'''Element-Highlighting''': Das Elements unter dem Mauszeiger wird rot umrandet.<br />
#'''Elemente einzeichnen''': Die Rahmen aller Elemente der Ansicht werden angezeigt.<br />
#'''Werkzeuge''': Auswahl, mit welchem Werkzeug aufgenommen werden soll. Die gewählte Aktion wird bei einem Klick auf die Anzeige ausgelöst. Dabei stehen folgende Aktionen zur Verfügung:<br />
#*Aktionen auf Elemente:<br />
#**Klicken: Kurzer Klick auf das Element über dem der Cursor steht. Zur genaueren Bestimmung, welches Element verwendet wird, benutzen Sie die Funktion Follow-Mouse oder Highlight-Selected.<br />
#**Element antippen: Ähnlich zum Klicken, nur dass zusätzlich die Dauer des Klicks aufgezeichnet wird. Dadurch sind auch längere Klicks möglich.<br />
#**Text setzen: Ermöglicht das Setzen eines Textes in Eingabefelder.<br />
#**Text löschen: Löscht den Text eines Eingabefelds.<br />
#*Aktionen auf das Gerät:<br />
#**Antippen: Löst einen Klick auf die Bildschirmposition aus, bei dem auch die Dauer berücksichtigt wird.<br />
#**Wischen: Wischen in einer geraden Linie vom Punkt des Drückens des Mausknopfes bis zum Loslassen. Die Dauer wird ebenfalls aufgezeichnet.<br />
#:Beachten Sie bei diesen Aktionen, dass das Ergebnis sich auf verschiedenen Geräten unterscheiden kann, bspw. bei verschiedenen Bildschirmauflösungen.<br />
#*Erstellen von Testablauf-Bausteinen<br />
#**Attribut prüfen: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Das Ergebnis triggert den entsprechenden Ausgang.<br />
#**Attribut zusichern: Vergleicht den Wert eines festgelegten Attributs des Elements mit einem vorgegebenen Wert. Bei Ungleichheit schlägt der Test fehl.<br />
#*Auto<br />
#:Ist das Auto-Werkzeug ausgewählt, können alle Aktionen durch spezifische Eingabeweise benutzt werden: ''Klicken'', ''Element antippen'' und ''Wischen'' funktionieren weiterhin durch Klicken, wobei sie anhand der Dauer und der Bewegung des Cursors unterschieden werden. Um ein ''Antippen'' auszulösen, halten Sie beim Klicken Strg gedrückt. Die übrigen Aktionen erhalten Sie durch einen Rechtsklick auf das Element in einem Kontextmenü.<br />
#'''Softkeys''': Nur unter Android. Simuliert das Drücken der Knöpfe Zurück, Home, Fensterliste und Power.<br />
#'''Home-Button''': Nur unter iOS ab expecco 2.11. Ermöglicht das Drücken des Home-Buttons. Funktioniert nur, wenn AssistiveTouch aktiviert ist und sich das Menü in der Mitte des oberen Bildschirmrands befindet.<br />
#'''Anzeige''': Zeigt einen Screenshot des Geräts. Aktionen werden mit der Maus je nach Werkzeug ausgelöst. Wenn eine neue Aktion eingegeben werden kann, hat das Fenster einen grünen Rahmen, sonst ist er rot.<br />
#'''Fenster an Bild anpassen''': Ändert die Größe des Fensters so, dass der Screenshot vollständig angezeigt werden kann.<br />
#'''Bild an Fenster anpassen''': Skaliert den Screenshot auf eine Größe, mit der er die volle Größe des Fensters ausnutzt.<br />
#'''Ausrichtung anpassen''': Korrigiert das Bild, falls dieses auf dem Kopf stehen sollte. Über den Pfeil rechts daneben kann das Bild auch um 90° gedreht werden, falls dies einmal nötig sein sollte. Die Ausrichtung des Bildes ist für die Funktion des Recorders unerheblich, dieser arbeitet ausschließlich auf den erhaltenen Elementen.<br />
#'''Skalierung''': Ändert die Skalierung des Screenshots. Kann auch über den Schieberegler rechts daneben angepasst werden.<br />
#'''Kontrollleuchte''': Zeigt den Zustand des Recorders an<br />
#:''grün'': Der Recorder ist bereit<br />
#:''rot'': Der Recorder ist blockiert, weil die Anzeige und die Elementliste aktualisiert werden<br />
#:''grau'': Der Recorder kann nicht mehr verwendet werden, da die Verbindung zum Gerät verloren gegangen ist<br />
<br />
;Verwendung<br />
Mit jedem Klick im Fenster wird eine Aktion ausgelöst und im Arbeitsbereich des GUI-Browsers aufgezeichnet. Dort können Sie das Aufgenommene abspielen, editieren oder daraus einen neuen Baustein erstellen. Zur Verwendung des Recorders lesen Sie auch Schritt 2 im Tutorial ([[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen|Android]] bzw. [[#Schritt_2:_Einen_Baustein_mit_dem_Recorder_erstellen_2|iOS]]).<br />
<br />
== AVD Manager und SDK Manager ==<br />
AVD Manager und SDK Manager sind beides Anwendungen von Android. Im Menü des Mobile Testing Plugins bietet expecco die Möglichkeit, diese zu starten. Ansonsten finden Sie diese Programme bei Ihrer Android-Installation. Mit dem AVD Manager können Sie AVDs, also Konfigurationen für Emulatoren, erstellen, bearbeiten und starten. Mit dem SDK Manager erhalten Sie einen Überblick über Ihre Android-Installation und können diese bei Bedarf erweitern.<br />
<br />
= XPath anpassen mithilfe des GUI-Browsers =<br />
Bausteine, die auf einem Gerät fehlerfrei funktionieren, tun dies auf anderen Geräten möglicherweise nicht. Auch können kleine Änderungen der App dazu führen, dass ein Baustein nicht mehr den gewünschten Effekt hat. Man sollte einen Baustein daher so robust formulieren, dass er für eine Vielzahl von Geräten verwendet werden kann und kleine Anpassungen an der App verkraftet. Dazu muss man das grundlegende Funktionsprinzip der Adressierung verstehen. Dies wird im Folgenden am Beispiel der App aus dem Tutorial erläutert.<br />
<br />
Die Ansicht der App setzt sich aus einzelnen Elementen zusammen. Dazu gehören die Schaltflächen ''GTIN-13 (EAN-13)'' und ''Verify'', das Eingabefeld der Zahl ''4006381333986'' und das Ergebnisfeld, in dem OK erscheint, wie auch alle anderen auf der Anzeige sichtbaren Dinge. Diese sichtbaren Elemente sind in unsichtbare Strukturelemente eingebettet. Alle Elemente zusammen sind in einer zusammenhängenden Hierarchie, dem Elementbaum, organisiert.<br />
<br />
[[Datei:MobileTestingGUIBrowser.png | frame | left | Abb. 1: Funktionen des GUI-Browsers]]<br />
<br clear="all"><br />
Sie können sich diesen Baum im GUI-Browser ansehen. Wechseln Sie dazu in den GUI-Browser (Abb. 1) und starten Sie eine beliebige Verbindung. Sobald die Verbindung aufgebaut ist, können Sie den gesamten Baum aufklappen (1) (Klick bei gedrückter Strg-Taste). Er enthält alle Elemente der aktuellen Seite der App.<br />
<br />
Ein Baustein, der nun ein bestimmtes Element verwendet, muss dieses eindeutig angeben, indem er dessen Position im Elementbaum mit einem Pfad im XPath-Format beschreibt. Dieses Format ist ein verbreiteter Web-Standard für XML-Dokumente und -Datenbanken, eignet sich aber genauso für Pfade im Elementbaum.<br />
<br />
Wenn Sie ein Element im Baum auswählen, wird unten der von expecco automatisch generierte XPath (2) für das Element angezeigt, der auch beim Aufzeichnen verwendet wird. Oberhalb davon in der Mitte des Fensters befindet sich eine Liste der Eigenschaften (3) des ausgewählten Elements. Man nennt diese Eigenschaften auch Attribute. Sie beschreiben das Element näher wie beispielsweise seinen Typ, seinen Text oder andere Informationen zu seinem Zustand. Links unten können Sie zur besseren Orientierung im Baum die ''Vorschau'' (4) aktivieren, um sich den Bildausschnitt des Elements anzeigen zu lassen.<br />
<br />
Der Elementbaum für gleiche Ansicht einer App kann sich je nach Gerät unterscheiden. Es sind diese Unterschiede, die verhindern, eine Aufnahme von einem Gerät unverändert auch auf allen anderen Geräten abzuspielen: Ein XPath, der im einen Elementbaum ein bestimmtes Element identifiziert, beschreibt nicht unbedingt das gleiche Element im Elementbaum auf einem anderen Gerät. Es kann stattdessen passieren, dass der XPath auf kein Element, auf ein falsches Element oder auf mehrere Elemente passt. Dann schlägt der Test fehl oder er verhält sich unerwartet.<br />
<br />
Man könnte natürlich für jedes Gerät einen eigenen Testfall schreiben. Das brächte aber unverhältnismäßigen Aufwand bei Testerstellung und -wartung mit sich. Das Problem lässt sich auch anders lösen, da ein jeweiliges Element nicht nur durch genau einen XPath beschrieben wird. Vielmehr erlaubt der Standard mithilfe verschiedener Merkmale unterschiedliche Beschreibungen für ein und dasselbe Element zu formulieren. Das Ziel ist daher, einen Pfad zu finden, der auf allen für den Test verwendeten Geräten funktioniert und überall eindeutig zum richtigen Element führt.<br />
<br />
Im Beispiel besteht die Verbindung zur Android-App aus dem Tutorial und der Eintrag des GTIN-13-Buttons ist ausgewählt (5). Dessen automatisch generierter XPath (2) kann beispielsweise so aussehen:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[@resource id='android:id/content']/android.widget.RelativeLayout/android.widget.Button[@resource-id='de.exept.expeccomobiledemo:id/gtin_13']</blockquote><br />
<br />
Er ist offensichtlich lang und unübersichtlich. Der sehr viel kürzere Pfad<br />
<br />
<blockquote>//*[@text='GTIN-13 (EAN-13)']</blockquote><br />
<br />
führt zum selben Element.<br />
<br />
Für die iOS-App lautet der automatisch generierte XPath für diesen Button beispielsweise<br />
<br />
<blockquote>//AppiumAUT/XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton[2]</blockquote><br />
bzw.<br />
<blockquote>//AppiumAUT/UIAApplication/UIAWindow[1]/UIAButton[2]</blockquote><br />
<br />
und kann kürzer als<br />
<br />
<blockquote>//*[@name='GTIN-13 (EAN-13)']</blockquote><br />
<br />
geschrieben werden.<br />
<br />
Sie können den Pfad entsprechend im GUI-Browser ändern und durch ''Pfad überprüfen'' (6) feststellen, ob er weiterhin auf das ausgewählte Element zeigt, was expecco mit ''Verify Path: OK'' (7) bestätigen sollte. Der erste, sehr viel längere Pfad, beschreibt den gesamten Weg vom obersten Element des Baumes bis hin zum gesuchten Button. Der zweite Pfad hingegen wählt mit * zunächst sämtliche Elemente des Baumes und schränkt die Auswahl dann auf genau die Elemente ein, die ein ''text''- bzw. ''name''-Attribut mit dem Wert ''GTIN-13 (EAN-13)'' besitzen, in unserem Fall also genau der eine Button, den wir suchen.<br />
<br />
Im folgenden werden Android-ähnliche Pfade zur Veranschaulichung verwendet. Die Elemente in iOS-Apps heißen zwar anders, wodurch andere Pfade entstehen; das Prinzip ist jedoch das gleiche.<br />
<br />
[[Datei:MobileTestingBaum1.png | frame | Abb. 2: Elementbaum einer fiktiven App]]<br />
<br />
Sie können solche Pfade mit Hilfe weniger Regeln selbst formulieren. Sehen Sie sich den einfachen Baum einer fiktiven Android-App in Abb. 2 an: Die Einrückungen innerhalb des Baumes geben die Hierarchie der Elemente wieder. Ein Element ist ein ''Kind'' eines anderen Elementes, wenn jenes andere Element das nächsthöhere Element mit einem um eins geringeren Einzug ist. Jenes Element ist das ''Elternelement'' des Kindes. Sind mehrere untereinander stehende Elemente gleich eingerückt, so sind sie also alle Kinder desselben Elternelements.<br />
<br />
Ein Pfad durch alle Ebenen der Hierarchie zum TextView-Element ist nun:<br />
<br />
<blockquote>//hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView</blockquote><br />
<br />
Die Elemente sind mit Schrägstrichen voneinander getrennt. Es fällt auf, dass der Name des ersten Elements nicht mit dem im Baum übereinstimmt. Das oberste Element in der Hierarchie heißt immer ''hierarchy'' (für iOS wäre es ''AppiumAUT''), expecco zeigt im Baum stattdessen den Namen der Verbindung an, damit man mehrere Verbindungen voneinander unterscheiden kann. Die weiteren Elemente tragen jeweils das Präfix ''android.widget.'', das im Baum zur besseren Übersicht nicht angezeigt wird. Bei IOS gibt es kein Präfix, das durch einen Punkt abgetrennt wäre, expecco 2.11 blendet aber entsprechend ''XCUIElementType'' am Anfang aus. Mit jedem Schrägstrich führt der Pfad über eine Eltern-Kind-Beziehung in eine tiefere Hierarchie-Ebene, d. h. ''FrameLayout'' ist ein Kindelement von ''hierarchy'', ''LinearLayout'' ist ein Kind von ''FrameLayout'' usw. Die in eckigen Klammern geschriebenen Wörter dienen nur als Orientierungshilfe im Baum. Sie gehören nicht zum Typ.<br />
<br />
Ein Pfad muss nicht beim Element ''hierarchy'' beginnen. Man kann den Pfad beginnend mit einem beliebigen Element des Baumes bilden. Man kann also verkürzt auch<br />
<br />
<blockquote>//android.widget.TextView</blockquote><br />
<br />
schreiben. Der Pfad führt zum selben ''TextView''-Element, da es nur ein Element dieses Typs gibt. Anders verhält es sich bei dem Pfad<br />
<br />
<blockquote>//android.widget.Button.</blockquote><br />
<br />
Da es zwei Elemente vom Typ ''Button'' gibt, passt dieser Pfad auf zwei Elemente, nämlich den Button, der mit "''An''" markiert ist, und den ''Button'', der mit "''Aus''" markiert ist. Es würde an dieser Stelle aber auch nicht helfen den langen Pfad von ''hierarchy'' aus beginnend anzugeben. Um einen mehrdeutigen Pfad weiter zu differenzieren, kann man explizit ein Element aus einer Menge wählen, indem man den numerischen Index in eckigen Klammern dahinter schreibt. Der Pfad aus dem obigen Beispiel lässt sich damit so anpassen, dass er eindeutig auf den ''Button'' mit der Markierung "''Aus''" weist:<br />
<br />
<blockquote>//android.widget.Button[1].</blockquote><br />
<br />
Ihnen fällt sicher auf, dass der Index eine 1 ist obwohl das zweite Element gemeint ist. Das kommt daher, dass die Zählung bei 0 beginnt. Der Button mit der Markierung "An" hat also die Nummer 0 und der ''Button'' mit der Markierung "''Aus''" hat die Nummer 1.<br />
<br />
Dieser Ansatz, einen expliziten Index zu verwenden, hat zwei Nachteile: Zum einen lässt sich an dem Pfad nur schwer ablesen welches Element gemeint ist, zum andern ist der Pfad sehr empfindlich schon gegenüber kleinsten Änderungen, wie zum Beispiel dem Vertauschen der beiden ''Button''-Elemente oder dem Einfügen eines weiteren ''Button''-Elements in der App.<br />
<br />
Es wäre daher wünschenswert, das gemeinte Element über eine ihm charakteristische Eigenschaft wie einen Attributwert, zu adressieren. Für Android-Apps eignet sich hierfür häufig das Attribut ''resource-id''. Im Idealfall muss bei der Entwicklung der App darauf geachtet werden, dass jedes Element eine eindeutige Id erhält. Die ''resource-id'' hat den großen Vorteil, dass sie unabhängig vom Text des Elements oder der Spracheinstellung des Geräts ist. Für iOS-Apps kann entsprechend das Attribut ''name'' verwendet werden, wenn es von der App sinnvoll gesetzt wird. Der XPath-Standard erlaubt solche Auswahlbedingungen zu einem Element anzugeben. Angenommen, der ''Button'' mit der Markierung "''Aus''" hat die Eigenschaft ''resource-id'' mit dem Wert ''off'' und der ''Button'' mit der Markierung "''An''" hat als ''resource-id'' den Wert ''on'', dann kann man als eindeutigen Pfad für den "Aus"-''Button''<br />
<br />
<blockquote>//android.widget.Button[@resource-id='off']</blockquote><br />
<br />
formulieren. Wie an dem Beispiel zu sehen werden solche Bedingungen wie ein Index in eckigen Klammern an den Elementtyp angehängt. Der Name eines Attributes wird mit einem @ eingeleitet und der Wert mit einem = in Anführungszeichen angehängt. Ist der Attributwert global eindeutig, kann man den vorausgehenden Pfad sogar durch den globalen Platzhalter * ersetzen, der auf jedes Element passt. Das obige Beispiel mit dem GTIN-13-''Button'' war ein solcher Fall.<br />
<br />
[[Datei:MobileTestingBaum2.png | frame | Abb. 3: Elementbaum einer fiktiven App mit Erweiterungen]]<br />
<br />
Abb. 3 zeigt eine Erweiterung des Beispiels aus Abb. 2. Die App hat nun ein weiteres, nahezu identisches ''LinearLayout'' bekommen. Die ''Buttons'' sind in ihren Attributen jeweils ununterscheidbar. Deshalb funktioniert der vorige Ansatz nicht, einen eindeutigen Pfad nur mithilfe eines Attributwerts zu formulieren. Offensichtlich unterscheiden sich aber ihre benachbarten ''TextViews''. Es ist möglich die jeweilige ''TextView'' in den Pfad mit aufzunehmen, um einen ''Button'' dennoch eindeutig zu adressieren. Ein Pfad zum ''Button'' mit der Markierung "''An''" unterhalb der ''TextView'' mit der Markierung "''Druckschalter''" kann dabei wie folgt aussehen:<br />
<br />
<blockquote>//android.widget.TextView[@resource-id='push']/../android.widget.Button[@resource-id='on']</blockquote><br />
<br />
Der erste Teil beschreibt den Pfad zu der ''TextView'' mit der Markierung "''Druckschalter''" und der ''resource-id'' mit dem Wert ''push''. Danach folgt ein Schrägstrich gefolgt von zwei Punkten. Die zwei Punkte sind eine spezielle Elementbezeichnung, die nicht ein Kindelement benennt, sondern zum Elternelement wechselt, in diesem Fall also das ''LinearLayout'', in dem die ''TextView'' eingebettet ist. Im Kontext dieses ''LinearLayout'' ist der restliche Pfad, nämlich der ''Button'' mit der ''resource-id'' mit dem Wert ''on'', eindeutig.<br />
<br />
Der XPath-Standard bietet noch sehr viel mehr Ausdrucksmittel. Mit der hier knapp vorgestellten Auswahl ist es aber bereits möglich für die meisten praktischen Testfälle gute Pfade zu formulieren. Eine vollständige Einführung in XPath ginge über den Umfang dieser Einführung weit hinaus. Sie finden zahlreiche weiterführende Dokumentationen im Web und in Büchern.<br />
<br />
Eine universelle Strategie zum Erstellen guter XPaths gibt es nicht, da sie von den Testanforderungen abhängt. In der Regel ist es sinnvoll, den XPath kurz und dennoch eindeutig zu halten. Häufig lassen sich Elemente über Eigenschaften identifizieren wie beispielsweise ihren Text. Will man aber gerade den Text eines Elements auslesen, kann dieser natürlich nicht im Pfad verwendet werden, da er vorher nicht bekannt ist. Ebenso wird der Text variieren, wenn die App mit verschiedenen Sprachen gestartet wird.<br />
<br />
Jeder Baustein, der auf einem Element arbeitet, hat einen Eingangspin für den XPath. Im GUI-Browser finden Sie in der Mitte oben eine Liste von Bausteinen mit Aktionen, die Sie auf das ausgewählte Element anwenden können. Suchen Sie den Baustein ''Click'' (8) im Ordner Elements und wählen Sie ihn aus (Abb. 1). Er wird im rechten Teil unter ''Test'' eingefügt, der Pin für den XPath ist mit dem automatisch generierten Pfad des Elements vorbelegt (9). Sie können den Baustein hier auch ausführen. Die Ansicht wechselt dann auf ''Lauf''. Ändert sich durch die Aktion der Zustand Ihrer App, müssen Sie den Baum anschließend aktualisieren (10).<br />
<br />
Wenn Sie in der unteren Liste eine Eigenschaft auswählen, wechselt die Anzeige der Bausteine zu ''Eigenschaften'', wo Sie die eigenschaftsbezogenen Bausteine finden. Wie bei den Aktionen können Sie auch hier einen Baustein auswählen, der dann rechts in Test mit dem Pfad des Elements und der ausgewählten Eigenschaft eingetragen wird, sodass Sie ihn direkt ausführen können.<br />
<br />
=<span id="troubleshooting"><!-- Referenced by error dialog on connection error --></span>Probleme und Lösungen=<br />
==Allgemeine Hinweise==<br />
*Wenn ein über USB angeschlossenes Android-Gerät nicht im Verbindungsdialog auftaucht, versuchen Sie, den USB-Verbindungstyp zu ändern. In der Regel sollten MTP oder PTP funktionieren. Siehe auch [[#Android-Ger.C3.A4t_vorbereiten|Android-Gerät vorbereiten]].<br />
*In manchen Fällen erscheint beim Verbinden eines iOS-Geräts über USB der Hinweis, das verwendete Kabel sei nicht zertifiziert. In diesem Fall hilft es nur, das entsprechende Kabel auszutauschen.<br />
*Beachten Sie, dass im [[#Recorder|Recorder]] auch Elemente berücksichtigt werden, die Sie auf dem Bildschirm nicht sehen. Schalten Sie daher das Element-Highlighting an oder nutzen Sie Follow-Mouse-Funktion und den Elementbaum im GUI-Browser, um festzustellen, ob das richtige Element verwendet wird.<br />
*Stellen Sie sicher, dass beim Verbindungsaufbau mit einem iOS-Gerät keine Alerts geöffnet sind. Der Aufbau schlägt sonst fehl, da die App nicht in den Vordergrund kommen kann. Siehe auch [[#iOS-Ger.C3.A4t_und_App_vorbereiten|iOS-Gerät und App vorbereiten]].<br />
*Um einen iOS-Simulator zu verwenden müssen Sie keine udid angeben. In Xcode erhalten Sie die Namen der verfügbaren Simulatoren. Starten Sie dazu Xcode und wählen Sie in der Menüleiste am oberen Bildschirmrand im Menü ''Window'' den Eintrag ''Devices''. Hier sind neben den angeschlossenen Geräten auch die verfügbaren Simulatoren aufgelistet. Beachten Sie dabei, dass auf Simulatoren keine ''.ipa''-Dateien sondern nur ''.app''-Dateien installiert werden können.<br />
*Bei Android-Geräten, die Softkeys automatisch ein- und ausblenden, kann es vorkommen, dass der Recorder im unteren Bereich Elemente abschneidet, die durch die Softkeys verdeckt würden, auch wenn sie zu diesem Zeitpunkt gar nicht angezeigt werden. In diesem Fall hift es, die Softkeys so einzustellen, dass sie permanent angezeigt werden.<br />
<br />
==Verbindungsaufbau schlägt fehl==<br />
Schlägt der Verbindungsaufbau mit dem Appium-Server fehl, erhalten Sie in expecco eine Fehlermeldung ähnlicher der unten abgebildeten.<br />
<br />
Falls der Fehler nicht durch eine der unten gelisteten Ursachen bedingt ist,<br />
kann es sein, daß die auf dem Gerät befindliche UI-Automator Anwendung nicht mehr richtig funktioniert<br />
(Anm. dies tritt auf einigen Geräten sporadisch auf - die Ursache dafür ist uns z.Z. noch nicht bekannt).<br />
Hier hilft es, die UI-Automator Anwendungen im Mobilgerät zu deinstallieren. <br />
Expecco wird diese dann mit dem nächsten Verbindungsaufbau selbst wieder installieren.<br />
<br />
Zur Deinstallation navigieren Sie auf dem Gerät zu: "''Einstellungen''" - "''Anwendungen''",<br />
und suchen in der Liste nach folgenden Einträgen:<br />
Appium Settings<br />
io.appium.uiautomator2.server<br />
io.appium.uiautomator2.server.test<br />
klicken Sie auf die jeweilige Anwendung und dann auf "''Deinstallieren''".<br />
<br />
Falls die nicht hilft, kann eventuell der Appium-Server log weiter helfen (diesen erreichen Sie über das "''Erweiterungen''" - "''Mobile Testing''" Menü von expecco)<br />
<br />
[[Datei:MobileTestingVerbindungsfehler.png]]<br />
<br />
Hier sehen Sie die Art des aufgetretenen Fehlers. Klicken Sie auf ''Details'' um nähere Informationen zu erhalten. Mögliche Fehler sind:<br />
*''org.openqa.selenium.remote.UnreachableBrowserException''<br />
:Der angegebene Server läuft nicht oder ist nicht erreichbar. Überprüfen Sie die Serveradresse.<br />
*''org.openqa.selenium.WebDriverException''<br />
:Lesen Sie in den Details in der ersten Zeile die Meldung hinter ''Original Error'':<br />
:*''Unknown device or simulator UDID''<br />
::Entweder ist das Gerät nicht richtig angeschlossen oder die udid stimmt nicht.<br />
:*''Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65''<br />
::Dieser Fehler kann verschiedene Ursachen haben. Entweder konnte tatsächlich der WebDriverAgent nicht gebaut werden, weil die Signierungseinstellungen falsch sind oder das passende Provisioning Profile fehlt. Lesen Sie dazu den Abschnitt zur Verbereitung unter [[#expecco_2.11|Mac OS mit expecco 2.11]]. Es kann auch sein, dass der WebDriverAgent auf dem Gerät nicht gestartet werden kann, weil sich beispielsweise ein Alert im Vordergrund befindet oder Sie dem Entwickler nicht vertraut haben.<br />
:*''Could not install app: 'Command 'ios-deploy [...] exited with code 253'''<br />
::Die angegebene App kann nicht auf dem iOS-Gerät installiert werden, weil es nicht im Provisioning Profile der App eingetragen ist.<br />
:*''Bad app: [...] App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name.'''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die Datei unter dem angegebenen Pfad auf dem Mac befindet.<br />
:*''packageAndLaunchActivityFromManifest failed.''<br />
::Die angegebene ''apk''-Datei ist vermutlich kaputt.<br />
:*''Could not find app apk at [...]''<br />
::Der Pfad zur App ist falsch. Stellen Sie sicher, dass sich die ''apk''-Datei m angegebenen Pfad befindet.</div>Ani