How to Automate UI Testing using Instruments for iOS app

Automate UI Testing using Instruments

An instrument is a powerful tool that can be used to automate UI testing. Instruments can also be used to collect data about the performance and behavior of one or more processes on the system and track that data over time. Although most instruments are geared toward gathering trace data, the User Interface instrument helps automate data collection. With it you can record user events while you gather your trace data. You can use this recording to reliably reproduce the same sequence of events over and over again.

Launching Instruments

Instruments is contained within the Xcode 4 toolset. Download Xcode from the App Store and install it onto your computer. After you have installed Xcode, you are ready to run Instruments. Instruments can be launched in one of three ways.

To run Instruments from Xcode

  1. Open Xcode.
  2. Choose Xcode > Open Developer Tool > Instruments.


Even though each instrument is different, there is one general workflow when collecting information from your app. This workflow is a four-step process.

  1. Choose a trace template
  2. Direct Instruments to your app
  3. Collect information from about your app
  4. Examine the collected information

For UI automation we will be using  Automation template in Instruments to execute scripts. An important benefit of the Automation instrument is that you can use it with other instruments to perform sophisticated tests such as tracking down memory leaks and isolating causes of performance problems.

Note: The Automation instrument only works with apps that have been code signed with a development provisioning profile. Apps signed with a distribution provisioning profile cannot be automated with the UI Automation programming interface.

Writing an automation test script

In instruments we use JavaScript for writing test scripts. To create a script

  1. Select the Automation trace template.
  2. Click Add > Create.
  3. Double-click New Script to change the name of the script.
  4. In the Detail pane, select Console to enter the code for your script.
  5. Choose a target for your script.
  6. Click the Play button at the bottom of the Console.


Selecting trace template


After you create the script, it can be used throughout the development of your app. You can do this by importing your saved script and running it with the Automation instrument.

To import a previously saved script

  1. Select the Automation trace template.
  2. Click Add > Import.
  3. Navigate to your saved script file and click Open

Accessing and Manipulating UI Elements

To perform an action on an element in your app, you explicitly identify that element in terms of the app’s element hierarchy. Each accessible element is inherited from the base element, UIAElement. Every element can contain zero or more other elements. Script can access individual elements by their position within the element hierarchy. However, you can assign a unique name to each element by setting the label attribute and making sure Accessibility is selected in Interface Builder for the control represented by that element.


The four properties used in the scripts to access elements are

  • name. Derived from the accessibility label
  • value. The current value of the control, for example, the text in a text field
  • elements. Any child elements contained within the current element, for example, the cells in a table view
  • parent. The element that contains the current element


Ethical Hacking – Part 1

Before going into details of how to ethical hacking we should be clear of what it is.

What is ethical hacking?

An ethical hacking is an attempt to penetrate networks and or computer systems, using the same method as a hacker would use for the purpose of finding and fixing computer security vulnerabilities.

Here are list of the hacking tools that are commonly required for hacking. This will be required for doing any type of ethical hacking.

Reconnaissance (and DNS)
  1. Dig – DNS lookup utility
  2. DNSMap – DNS mapping is a mechanism which allows hosts on a private LAN to use DNS Services even if the address of an actual DNS Server is unknown.
  3. DNSTracer – Trace DNS queries to the source
  4. DNSWalk – Checks DNS zone information using nameserver lookups
  5. Netmask – Helps determine network masks
  6. Relay Scanner – This program is used to test SMTP servers for Relaying problems
  7. TCPTraceroute – Traceroute implementation using TCP packets
  8. Firewalk – Firewalk is a network auditing tool that attempts to determine what transport protocols a given gateway will pass.
  1. Amap – Performs fast and reliable application protocol detection, independent of the TCP/UDP port they are being bound to.
  2. Curl – Get a file from an HTTP, HTTPS or FTP server
  3. Fping – Sends ICMP ECHO_REQUEST packets to network hosts
  4. Hping3 – Active Network Smashing Tool
  5. HTTprint – A web server fingerprinting tool
  6. Ike-Scan – IPsec VPN scanning, fingerprinting and testing tool
  7. MetoScan – HTTP method scanner
  8. Nmap – The Network Mapper
  9. Netcat – TCP/IP swiss army knife
  10. P0f – Passive OS fingerprinting and masquerade detection utility
  11. Zenmap – The Network Mapper Front End
Password Cracking
  1. Chntpw – NT SAM password recovery utility
  2. Rainbowcrack – Crack LM, MD5 and SHA1 hashes
  3. THC PPTP Bruter – A brute forcing program against PPTP VPN endpoints (TCP port 1723)
  4. VNCrack – Crack VNC passwords
  5. John the ripper – A fast password cracker
Network Sniffing
  1. DHCP Dump – DHCP packet dumper
  2. Dsniff – Password sniffer
  3. SSLDump – Dump SSL traffic on a network
  4. Ntop – Displays top network users
  5. Wireshark – Interactively dump and analyze network traffic
Spoofing (or Masquerading)
  1. File2cable – Sends a file as a raw ethernet frame
  2. Netsed – Network packet streaming editor
  3. Sing – Send ICMP Nasty Garbage packets to network hosts
  4. TCPreplay – Replay network traffic stored in pcap files
Wireless Networking Utilities
  1. Aircrack-ng – Aircrack-ng is an 802.11 WEP and WPA-PSK keys cracking program that can recover keys once enough data packets have been captured.
  2. Kismet – Wireless sniffing and monitoring
  3. THC Leap Cracker – The THC LEAP Cracker Tool suite contains tools to break the NTChallengeResponse encryption technique e.g. used by Cisco Wireless LEAP Authentication.
  4. WEPCrack – WEPCrack is an open source tool for breaking 802.11 WEP secret keys.
  5. WIDZ – Wireless Intrusion Detection System
  6. Cowpatty – Brute-force dictionary attack against WPA-PSK
  1. GDB – The GNU Debugger.
  2. Hexdump – ASCII, decimal, hexadecimal and octal dump tool.
  3. Hexedit – View and edit file in hexadecimal or in ASCII
  4. Wipe – Securely erase files
  5. Madedit -Text/Hex Editor

Next part will have how to use these tools to exploit vulnerabilities.


Using Selenium with JMeter

To use Selenium Webdriver with JMeter, install “Webdriver” plugins. The WebDriver sampler is useful if you want to test for performance AJAX or GWT based web applications.

Download WebDriver plugins from

Unzip the files and copy in the lib folder under JMeter home directory.

To test if WebDriver plugins installed open Jmeter and test if there is jp@gc – Firefox Driver Config.

*If not, check your JMeter’s lib folder.
 Selenium Webdriver SamplerAdd the Webdriver sampler and Firefox or chrome driver config element. Insert the following code to launch Bing search and search for a text. Also add tree listener to view the result.
var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(
var wait = new support_ui.WebDriverWait(WDS.browser, 20000)
var searchField = WDS.browser.findElement('sb_form_q'))
var button = WDS.browser.findElement('sb_form_go'))
Explanation of the code
  • The code starts with the import Java packages “org.openqa.selenium” and “” which will allow you to use the WebDriver classes.
  • WDS.sampleResult.sampleStart() and WDS.sampleResult.sampleEnd() captures sampler’s time and will track it. You can remove them, the script will still work but you will not get load time
  • WDS.browser.get(‘’) – opens the browser with Bing search website
  • var searchField = WDS.browser.findElement(‘sb_form_q’)) – saves the search text box in searchField varialble
  • – Clicks the search field to make it active
  • searchField.sendKeys([‘testing’]) – Enters text to search
  • var button = WDS.browser.findElement(‘sb_form_go’)) – Saves search button in a variable
  • – clicks on the search button.

You are now ready to go. Do let us know your experience in using Selenium with JMeter

Selenium WebDriver – 5 Minute Getting Started Guide

Selenium 2.0 is commonly called as Selenium WebDriver  as it is integrated with WebDriver API. WebDriver is designed to provide a simple and concise programming interface in addition to addressing some limitations in the Selenium-RC API. Selenium WebDriver support dynamic web pages where element of a Page may change without the page itself being reloaded. Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation.

Continue reading “Selenium WebDriver – 5 Minute Getting Started Guide”

Distributed testing in Jmeter

You have reached the limit of one machine while doing your load testing and now want to distribute your load from different machines. In Jmeter it is commonly called as distributed load testing or remote testing.

Distributed testing or remote testing have 3 parts: JMeter Master, JMeter Slaves and Target.

Following figure explains the relationship between them.




Distributed setup prerequistie

1. All firewalls in JMeter master and slave machines should be turned off

2. All machines should be in same subnet

3. Use same version of JMeter in all machines( master and slaves)


Setting up the environment

Setup consists of  3 parts:

Master – running the JMeter GUI/command which controls the test

Slave – the system running the JMeter server, which takes command from the GUI/master and send request to the Target system.

Target – The web server which is to be load/stress tested.

Slave configuration

Make sure jmeter-sever.bat have proper path to rmiregistry.

Master Configuration

  • Open and edit the line “remote_hosts=”.
  • Add IP address of the slave machines e.g.: “remote_hosts=,,192.168.8”


Starting the Distributed test

  • Start jmeter-server.bat in all slave machines
  • Start jmeter.bat in master machine and open the test plan to run. Use remote start or remote start all option from the menu. Alternatively, you can use command prompt to run the test script as shown below.

jmeter -n -t my_test.jmx -l log.jtl –r

-n this specifies JMeter is to run in non-gui mode

-t [name of JMX file that contains the Test Plan].

-l [name of JTL file to log sample results to].

-r Run all remote servers specified in (or remote servers specified on command line by overriding properties)