What you are looking for, Automated user interface
In this example, the JavaScript code changes the orientation of the device, for example:
var target = UIATarget.localTarget(); var app = target.frontMostApp(); //set orientation to landscape left target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPELEFT); UIALogger.logMessage("Current orientation now " + app.interfaceOrientation()); //reset orientation to portrait target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT); UIALogger.logMessage("Current orientation now " + app.interfaceOrientation());
For testing purposes, if your layout has changed to RTL or LTR, you can try to access certain elements of the user interface and check their contents for the expected content. So, here is another example to check the contents of TableViewCell from white papers:
The essence of testing is to verify that each test is completed and that it passed or failed. In this code example, test testName is run to determine if a recipe element of a valid element whose name begins with "Tarte" exists in the recipe table view. First, a local variable is used to determine the criteria of a cell:
var cell = UIATarget.localTarget().frontMostApp().mainWindow() \ .tableViews()[0].cells().firstWithPredicate("name beginswith 'Tarte'");
Next, the script uses the isValid method to check for the presence of a valid element matching these criteria in the recipe table view.
if (cell.isValid()) { UIALogger.logPass(testName); } else { UIALogger.logFail(testName); }
If a valid cell is found, the code logs an error message for the testName test; if not, it logs an error message.
Note that this test defines firstWithPredicate and “name begins with“ Tart. ”These criteria provide a link to the cell for“ Tarte aux Fraises, ”which works for the default data already in the Recipes sample application. If, however, the user adds a recipe for "Tarte aux Framboises", this example may or may not produce the desired results.
If you want to test a specific circuit:
Running the script automation tool in Xcode After creating a custom automation template, you can run your script test from Xcode by following these steps: Open the project in Xcode. In the "Schema" pop-up menu (in the toolbar of the workspace window) select "Edit Schema" for the scheme with which you would like to use a script. Select Profile in the left column of the schematic editing dialog box. Select your application from the Executable Files pop-up menu. Select a custom automation tool template from the Tool pop-up menu. Click "OK" to confirm your changes and cancel the dialog of the circuit editor. Choose Product> Profile. Tools run and execute your test script.