Integrating Custom XCTest Code & Scriptless

You are here:
< All Topics

XCTest Custom Scripts

  • Click on Add Custom Script
  • Below the Popup box will appear on the screen.

 

 

  • Add a Test Case Name and Description.
  • Add your scripts on Custom Script.
  • Click on Save.

 

 

Actions

Call Custom Script

call custom script in TestGrid Automation Testing Tool

    • This action is for Android, iOS, and Web.
    • This action is used to call the custom script that you created in a custom script section.

 

iOS XCTest Custom Script

    • For the iOS XCTest framework, we can write custom scripts in Swift.
    • We can use the “app” object to access all methods of the XCUIApplication class.
    • Following are some examples:

 

Sample 1
app.pinch(withScale: 3, velocity: 1)
Sample 2
let windowWidth = app.windows.element(boundBy: 0).frame.size.width
let windowHeight = app.windows.element(boundBy: 0).frame.size.height
let point1 = CGPoint(x: windowWidth/2, y: (windowHeight/2)+10)
tapAtCoordinates(point: point1)
Sample 3
var element =  app.staticTexts.containing(.staticText, identifier: "keyValue").element(boundBy: 0)
element.tap()
Sample 4
let windowWidth = app.windows.element(boundBy: 0).frame.size.width
let windowHeight = app.windows.element(boundBy: 0).frame.size.height
let point1 = CGPoint(x: windowWidth/2, y: windowHeight/2)
longPressAtCoordinates(point: point1, seconds: 3)
Sample 5
print(app.debugDescription)

 

As simple as that! Happy Testing 😇

 

Table of Contents