Question

AS I am using UIAutomation tool of Instruments , I need information in the following:

1)is there any procedure for giviing data dynamically. For example, if I need to use this script to test different data for Textfield, how I can achive without modifying the script for the hardcoded Textfield value?I dont want to do through manual loop in javascript? Is it possible to use Sqlite through which javascript will take List of textfield values? I am new UIautomation in instruments in ios.The following line is the first command in script

        UIATarget.localTarget().frontMostApp().mainWindow().textFields()["username"].setValue("test");

But I want to give setvalue in following command through terminal without altering actual script

  instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate <full_path_to_application> -e UIASCRIPT <path_to_script.js> -e UIARESULTSPATH <output_results_path>

Anybody can help how to give setvalue through above command dyanmically? is anyother way to give setvalue for username dynamically without altering script manually?

2)is it possible to verify the components and attributes of the screen through javascript in UIAutomation?

Was it helpful?

Solution

1. Yes. You should write a system-level script that generates JavaScript code from the data and calls the Instruments from command line. A sample script is:

#!/bin/bash
echo 'var thisIsAGeneratedInput = "Sample Input variable";' > input.js
instruments -t test.tracetemplate your_app_with_path.app -e UIASCRIPT test.js

The file "test.js" should look like:

#import "input.js"
UIALogger.logMessage(thisIsAGeneratedInput);

2. The function value() is the proper way to get the requested information, name() returns the accessibility ID if given. Note: in XCode 5 value() might not work, use name() for workaround, but prior to version 5 it was OK.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top