Upgrade from v1.6.6 to v1.7.0

This guide will assist in upgrading your AltUnity projects from v1.6.6 to v1.7.0.

AltUnity v1.7.0 is a major update to the framework with a brand new internal communication protocol and as such includes a small number of breaking changes. All changes are listed below, organized by drivers along with how to upgrade your code to work with AltUnity v1.7.0.

To learn more about what’s new in AltUnity v1.7.0, read the v1.7.0 section from our changelog.

Dotnet

AltUnity Object

  1. In case of GetComponentProperty command, we made the return type generic T instead of string.

Replace:

var propertyValue = altUnityObject.GetComponentProperty(componentName, propertyName);

With:

T propertyValue = altUnityObject.GetComponentProperty<T>(componentName, propertyName);

2. In case of SetComponentProperty command, we changed the type of parameter value from string to object. SetComponentProperty returns now void instead of string.

Replace:

altUnityObject.SetComponentProperty("AltUnityExampleScriptCapsule", "AltUnitySampleClass.testInt", "2");

With:

altUnityObject.SetComponentProperty("AltUnityExampleScriptCapsule", "AltUnitySampleClass.testInt", 2);

3. In case of CallComponentMethod command, we changed the types of parameters and typeOfParameters from string to array. CallComponentMethod returns now generic T instead of string.

Replace:

altUnityObject.CallComponentMethod("UnityEngine.Transform", "Rotate", "10?10?10" }, "System.Single?System.Single?System.Single" }, "UnityEngine.CoreModule");

With:

altUnityObject.CallComponentMethod<string>("UnityEngine.Transform", "Rotate", new[] { "10", "10", "10" }, new[] { "System.Single", "System.Single", "System.Single" }, "UnityEngine.CoreModule");

AltUnity Driver

1. In case of CallStaticMethod command, we changed the types of parameters and typeOfParameters from string to array. CallStaticMethod returns now generic T instead of string.

Replace:

altUnityDriver.CallStaticMethods("UnityEngine.PlayerPrefs", "SetInt", "Test?1");

With:

altUnityDriver.CallStaticMethod<string>("UnityEngine.PlayerPrefs", "SetInt", new[] { "Test", "1" });
  1. In case of GetStaticProperty command, we made the return type generic T instead of string.

Replace:

var width = altUnityDriver.GetStaticProperty("UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule");

With:

var width = altUnityDriver.GetStaticProperty<int>("UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule");
  1. We replaced the WaitForObjectWithText command with WaitForObject.

Replace:

var altUnityObject = altUnityDriver.WaitForObjectWithText(By.NAME, name, text);

With:

var altUnityObject = altUnityDriver.WaitForObject(By.TEXT, "text");
  1. We removed the “MoveMouseAndWait” command and now the “MoveMouse” will take a wait argument.

Replace:

altUnityDriver.MoveMouseAndWait(coordinates, duration);

With:

altUnityDriver.MoveMouse(coordinates, duration, wait: true);
  1. We removed the “PressKeyAndWait” command and now the “PressKey” will take a wait argument.

Replace:

altUnityDriver.PressKeyAndWait(keyCode);

With:

altUnityDriver.PressKey(keyCode, wait: true);
  1. We removed the “ScrollMouseAndWait” command and now the “Scroll” will take a wait argument.

Replace:

altUnityDriver.ScrollMouseAndWait();

With:

altUnityDriver.Scroll(wait: true);
  1. We removed the “SwipeAndWait” command and now the “Swipe” will take a wait argument.

Replace:

altUnityDriver.SwipeAndWait(positions);

With:

altUnityDriver.Swipe(positions, wait: true);
  1. We removed the “MultiPointSwipeAndWait” command and now the “MultiPointSwipe” will take a wait argument.

Replace:

altUnityDriver.MultiPointSwipeAndWait(positions);

With:

altUnityDriver.MultiPointSwipe(positions, wait: true);
  1. We removed the “TiltAndWait” command and now the “Tilt” will take a wait argument.

Replace:

altUnityDriver.TiltAndWait(acceleration);

With:

altUnityDriver.Tilt(acceleration, wait: true);

Python

AltUnity Object

  1. In case of get_component_property command, we changed the return type from string to object.

Replace:

result = altobject.get_component_property("AltUnityExampleScriptCapsule", "arrayOfInts")
assert result == "[1, 2, 3]"

With:

result = altobject.get_component_property("AltUnityExampleScriptCapsule", "arrayOfInts")
assert result == [1, 2, 3]

2. In case of set_component_property command, we changed the type of parameter value from string to object. set_component_property returns now void instead of string.

Replace:

altUnityObject.set_component_property("AltUnityExampleScriptCapsule", "arrayOfInts", "[2, 3, 4]")

With:

altUnityObject.set_component_property("AltUnityExampleScriptCapsule", "arrayOfInts", [2, 3, 4])

3. In case of call_component_method command, we changed the types of parameters and typeOfParameters from string to array. call_component_method returns now object instead of string.

Replace:

altUnityObject.call_component_method("Capsule", "Jump", "setFromMethod")

With:

altUnityObject.call_component_method("AltUnityExampleScriptCapsule", "Jump", ["setFromMethod"])

AltUnity Driver

1. In case of call_static_method command, we changed the types of parameters and typeOfParameters from string to array. call_static_method returns now object instead of string.

Replace:

altUnityDriver.call_static_method("UnityEngine.PlayerPrefs", "SetInt", "[Test, 1]")

With:

altUnityDriver.call_static_method("UnityEngine.PlayerPrefs", "SetInt", ["Test", "1"])
  1. In case of get_static_property command, we return object instead of string.

Replace:

var width = altUnityDriver.get_static_property("UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule")

With:

int width = altUnityDriver.get_static_property("UnityEngine.Screen", "currentResolution.width", "UnityEngine.CoreModule")
  1. We replaced the wait_for_object_with_text command with wait_for_object.

Replace:

var altUnityObject = altUnityDriver.wait_for_object_with_text(By.NAME, name, text)

With:

var altUnityObject = altUnityDriver.wait_for_object(By.TEXT, "text")
  1. We removed the move_mouse_and_wait command and now the move_mouse will take a wait argument.

Replace:

altUnityDriver.move_mouse_and_wait(coordinates, duration)

With:

altUnityDriver.move_mouse(coordinates, duration, wait = True)
  1. We removed the press_key_and_wait command and now the press_key will take a wait argument.

Replace:

altUnityDriver.press_key_and_wait(keyCode)

With:

altUnityDriver.press_key(keyCode, wait = True)
  1. We removed the scroll_mouse_and_wait command and now the scroll will take a wait argument.

Replace:

altUnityDriver.scroll_mouse_and_wait()

With:

altUnityDriver.scroll(wait = True)
  1. We removed the swipe_and_wait command and now the swipe will take a wait argument.

Replace:

altUnityDriver.swipe_and_wait(start, end)

With:

altUnityDriver.swipe(start, end, wait = True)
  1. We removed the multipoint_swipe_and_wait command and now the multipoint_swipe will take a wait argument.

Replace:

altUnityDriver.multipoint_swipe_and_wait(positions)

With:

altUnityDriver.multipoint_swipe(positions, wait = True)
  1. We removed the tilt_and_wait command and now the tilt will take a wait argument.

Replace:

altUnityDriver.tilt_and_wait(acceleration)

With:

altUnityDriver.tilt(acceleration, wait = True)

Java

AltUnity Object

1. In case of getComponentProperty command, we made the return type generic T instead of string. AltGetComponentPropertyParameters was renamed to AltGetComponentPropertyParams.

Replace:

AltGetComponentPropertyParameters altGetComponentPropertyParameters = new AltGetComponentPropertyParameters.Builder(
    componentName, propertyName).build();
String propertyValue = altUnityObject.getComponentProperty(altGetComponentPropertyParameters);
assertEquals(propertyValue, "13000");

With:

AltGetComponentPropertyParams altGetComponentPropertyParams = new AltGetComponentPropertyParams.Builder(
    componentName, propertyName).build();
int propertyValue = altUnityObject.getComponentProperty(altGetComponentPropertyParams,Integer.class);
assertEquals(propertyValue, 13000);

2. In case of setComponentProperty command, we changed the type of parameter value from String to Object. setComponentProperty returns now void instead of String. AltSetComponentPropertyParameters was renamed to AltSetComponentPropertyParams.

Replace:

AltSetComponentPropertyParameters altSetComponentPropertyParameters = new AltSetComponentPropertyParameters.Builder(componentName, propertyName, "2").build();
altUnityObject.setComponentProperty(altSetComponentPropertyParameters);

With:

AltSetComponentPropertyParams altSetComponentPropertyParams = new AltSetComponentPropertyParams.Builder(componentName, propertyName, 2).build();
altUnityObject.setComponentProperty(altSetComponentPropertyParams);

3. In case of callComponentMethod command, we changed the types of parameters and typeOfParameters from String to Array. callComponentMethod returns now generic T instead of String. AltCallComponentMethodParameters was renamed to AltCallComponentMethodParams.

Replace:

AltCallComponentMethodParameters altCallComponentMethodParameters = new AltCallComponentMethodParameters.Builder("Altom.AltUnityTester.AltUnityRunner", "OnApplicationPause", "true").withTypeOfParameters("System.Boolean").build();
altUnityObject.callComponentMethod(altCallComponentMethodParameters);

With:

AltCallComponentMethodParams altCallComponentMethodParams = new AltCallComponentMethodParams.Builder("Altom.AltUnityTester.AltUnityRunner", "OnApplicationPause", new Object[] { true }).withTypeOfParameters(new String[] { "System.Boolean" }).build();
altUnityObject.callComponentMethod(altCallComponentMethodParams, Void.class);

AltUnity Driver

1. In case of callStaticMethod command, we changed the types of parameters and typeOfParameters from string to array. callStaticMethod returns now generic T instead of string. AltCallStaticMethodParameters was renamed to AltCallStaticMethodParams.

Replace:

AltCallStaticMethodParameters altCallStaticMethodParameters = new AltCallStaticMethodParameters.Builder("UnityEngine.PlayerPrefs", "SetInt", "Test?1").build();
altUnityDriver.callStaticMethods(altCallStaticMethodParameters);

With:

AltCallStaticMethodParams altCallStaticMethodParams = new AltCallStaticMethodParams.Builder("UnityEngine.PlayerPrefs", "SetInt", new Object[] {"Test", 1}).build();
altUnityDriver.callStaticMethod(altCallStaticMethodParams, String.class);
  1. In case of getStaticProperty command, we made the return type generic T instead of string.

Replace:

AltGetComponentPropertyParameters altGetComponentPropertyParameters = new AltGetComponentPropertyParameters.Builder("UnityEngine.Screen", "currentResolution.width").withAssembly("UnityEngine.CoreModule").build();
String width = altUnityDriver.getStaticProperty(altGetComponentPropertyParameters);

With:

AltGetComponentPropertyParams altGetComponentPropertyParams = new AltGetComponentPropertyParams.Builder("UnityEngine.Screen", "currentResolution.width").withAssembly("UnityEngine.CoreModule").build();
int width = altUnityDriver.getStaticProperty(altGetComponentPropertyParams, Integer.class);

3. We replaced the waitForObjectWithText command with waitForObject. Instead of AltWaitForObjectWithTextParameters we use AltWaitForObjectsParams.

Replace:

String name = "CapsuleInfo";
AltFindObjectsParameters altFindObjectsParameters = new AltFindObjectsParameters.Builder(AltUnityDriver.By.NAME,
    name).build();
String text = altUnityDriver.findObject(altFindObjectsParameters).getText();

AltWaitForObjectWithTextParameters altWaitForObjectsParameters = new AltWaitForObjectWithTextParameters.Builder(
    altFindObjectsParameters, text).build();
AltUnityObject altElement = altUnityDriver.waitForObjectWithText(altWaitForObjectsParameters);

With:

String name = "CapsuleInfo";
AltWaitForObjectsParams waitObjectParams = new AltFindObjectsParams.Builder(AltUnityDriver.By.PATH,
        "//CapsuleInfo[@text=Capsule Info"]).build();

AltUnityObject altElement = altUnityDriver.waitForObject(waitObjectParams);

4. We removed the moveMouseAndWait command and now the moveMouse will take a wait argument. AltMoveMouseParameters was renamed to AltMoveMouseParams.

Replace:

AltMoveMouseParameters altMoveMouseParameters = new AltMoveMouseParameters.Builder(capsule.getScreenPosition()).withDuration(0.1f).build();
altUnityDriver.moveMouseAndWait(altMoveMouseParameters);

With:

AltMoveMouseParams altMoveMouseParams = new AltMoveMouseParams.Builder(capsule.getScreenPosition()).withDuration(0.1f).withWait(true).build();
altUnityDriver.moveMouse(altMoveMouseParams);

5. We removed the pressKeyAndWait command and now the pressKey will take a wait argument. AltPressKeyParameters was renamed to AltPressKeyParams.

Replace:

AltPressKeyParameters altPressKeyParameters = new AltPressKeyParameters.Builder(AltUnityKeyCode.O).withDuration(1).withPower(1).build();
altUnityDriver.pressKeyAndWait(altPressKeyParameters);

With:

AltPressKeyParams altPressKeyParams = new AltPressKeyParams.Builder(AltUnityKeyCode.O).withDuration(1).withPower(1).withWait(true).build();
altUnityDriver.pressKey(altPressKeyParams);

6. We removed the scrollMouseAndWait command and now the scroll will take a wait argument. scroll waits by default. You can change that using .withWait(false).

Example:

AltScrollParams altScrollParams = new AltScrollParams.Builder().withSpeed(30).withDuration(20).withWait(false).build();
altUnityDriver.scroll(altScrollParams);

7. We removed the swipeAndWait command and now the swipe will take a wait argument. swipe waits by default. You can change that using .withWait(false).

Example:

AltSwipeParams altSwipeParams = new AltSwipeParams.Builder(altElement1.getScreenPosition(), altElement2.getScreenPosition()).withDuration(2).withWait(false).build();
altUnityDriver.swipe(altSwipeParams);

8. We removed the multiPointSwipeAndWait command and now the multiPointSwipe will take a wait argument. multiPointSwipe waits by default. You can change that using .withWait(false).

Example:

AltMultiPointSwipeParams altMultiPointSwipeParams = new AltMultiPointSwipeParams.Builder(positions).withDuration(2).withWait(false).build();
altUnityDriver.multiPointSwipe(altMultiPointSwipeParams);

9. We removed the tiltAndWait command and now the tilt will take a wait argument. tilt waits by default. You can change that using .withWait(false).

Example:

AltTiltParams altTiltParams = new AltTiltParams.Builder(new Vector3(1, 1,
            1)).withDuration(1).withWait(false).build();
altUnityDriver.tilt(altTiltParams);
  1. In case of the setTimeScale command, its argument was changed from float to AltSetTimescaleParams.

Example:

altUnityDriver.setTimeScale(new AltSetTimeScaleParams.Builder(1f).build());
  1. In case of the unloadScene command, its argument was changed from String to AltUnloadSceneParams.

Example:

altUnityDriver.unloadScene(new AltUnloadSceneParams.Builder("Scene 2 Draggable Panel").build());
  1. In case of the beginTouch command, its argument was changed from Vector2 to AltBeginTouchParams.

Example:

altUnityDriver.beginTouch(new AltBeginTouchParams.Builder(draggableArea.getScreenPosition()).build());
  1. In case of the moveTouch command, its arguments were grouped in AltMoveTouchParams.

Example:

altUnityDriver.moveTouch(new AltMoveTouchParams.Builder(fingerId, newPosition).build());
  1. In case of the endTouch command, its argument was changed from int to AltEndTouchParams.

altUnityDriver.endTouch(new AltEndTouchParams.Builder(fingerId).build());