### Install and Start Appium Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-appium This snippet outlines the necessary shell commands to install Appium and its client library. It includes installing Node.js via Homebrew, installing Appium globally using npm, installing the 'wd' client, and starting the Appium server in the background. ```shell > brew install node # get node.js > npm install -g appium # get appium > npm install wd # get appium client > appium & # start appium ``` -------------------------------- ### AltTester SDK C# Server-Side Example Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud Illustrates a server-side execution setup for C# tests using the AltTester SDK within a platform like BitBar. This involves uploading all necessary components and using a script to manage installation, test execution, and report generation. ```bash # Example run-tests.sh for C# server-side execution # Install .NET SDK # ... installation commands for .NET ... # Restore dependencies dotnet restore # Run tests dotnet test # Prepare test report # ... report generation commands ... ``` -------------------------------- ### Python AltDriver Initialization and Test Example Source: https://alttester.com/docs/sdk/latest/pages/get-started Example Python test using unittest and AltDriver to load a scene, interact with UI elements, and assert element state. Includes driver setup and teardown. ```python import unittest from alttester import AltDriver, By class MyFirstTest(unittest.TestCase): alt_driver = None @classmethod def setUpClass(cls): cls.alt_driver = AltDriver() @classmethod def tearDownClass(cls): cls.alt_driver.stop() def test_open_close_panel(self): self.alt_driver.load_scene('Scene 2 Draggable Panel') self.alt_driver.find_object(By.NAME, "Close Button").tap() self.alt_driver.find_object(By.NAME, "Button").tap() panel_element = self.alt_driver.wait_for_object(By.NAME, "Panel") self.assertTrue(panel_element.enabled) ``` -------------------------------- ### AltTester SDK BeginTouch API Source: https://alttester.com/docs/sdk/latest/pages/commands Documentation for the BeginTouch command, which simulates starting a touch on the screen. Includes parameter details, return values, and usage examples across multiple languages. ```APIDOC BeginTouch Simulates starting of a touch on the screen. To further interact with the touch use MoveTouch and EndTouch. Parameters: coordinates | AltVector2 (C#) / Vector2 (Java) / list/tuple/dict (Python, Robot) | Yes | Screen coordinates. Returns: int - the fingerId. Related Commands: MoveTouch: Updates the position of an ongoing touch. EndTouch: Ends an ongoing touch. Examples: C#: [Test] publicvoidTestNewTouchCommands() { var draggableArea=altDriver.FindObject(By.NAME,"Drag Zone"); var initialPosition=draggableArea.GetScreenPosition(); int fingerId=altDriver.BeginTouch(draggableArea.GetScreenPosition()); AltVector2newPosition=newAltVector2(draggableArea.x+20,draggableArea.y+10); altDriver.MoveTouch(fingerId,newPosition); altDriver.EndTouch(fingerId); draggableArea=altDriver.FindObject(By.NAME,"Drag Zone"); Assert.AreNotEqual(initialPosition,draggableArea.GetScreenPosition()); } Java: @Test publicvoidtestNewTouchCommands()throwsInterruptedException{ AltFindObjectsParamsaltFindObjectsParameters1=newAltFindObjectsParams.Builder( AltDriver.By.NAME,"Drag Zone").build(); AltObjectdraggableArea=altDriver.findObject(altFindObjectsParameters1); Vector2initialPosition=draggableArea.getScreenPosition(); intfingerId=altDriver.beginTouch(newAltBeginTouchParams.Builder(initialPosition).build()); Vector2newPosition=newVector2(draggableArea.x+20,draggableArea.y+10); altDriver.moveTouch(newAltMoveTouchParams.Builder(fingerId,newPosition).build()); altDriver.endTouch(newAltEndTouchParams.Builder(fingerId).build()); draggableArea=altDriver.findObject(altFindObjectsParameters1); assertNotEquals(initialPosition.x,draggableArea.getScreenPosition().x); assertNotEquals(initialPosition.y,draggableArea.getScreenPosition().y); } Python: deftest_new_touch_commands(self): self.alt_driver.load_scene('Scene 2 Draggable Panel') draggable_area = self.alt_driver.find_object(By.NAME, 'Drag Zone') initial_position = draggable_area.get_screen_position() finger_id = self.alt_driver.begin_touch(draggable_area.get_screen_position()) self.alt_driver.move_touch(finger_id, [int(draggable_area.x) + 10, int(draggable_area.y) + 10]) self.alt_driver.end_touch(finger_id) draggable_area = self.alt_driver.find_object(By.NAME, 'Drag Zone') self.assertNotEqual(initial_position, draggable_area) Robot: ${draggable_area}=Find ObjectNAMEDrag Zone ${initial_position}=Get Screen Position${draggable_area} ${finger_id}=Begin Touch${initial_position} ${draggable_area_x}=Get Object X${draggable_area} ${draggable_area_y}=Get Object Y${draggable_area} ${new_x}=Evaluate${draggable_area_x}+10 ${new_y}=Evaluate${draggable_area_y}+10 ${new_screen_position}=Create List${new_x}${new_y} Move Touch${finger_id}${new_screen_position} End Touch${finger_id} ${draggable_area}=Find ObjectNAMEDrag Zone ${final_position}=Get Screen Position${draggable_area} Should Not Be Equal${initial_position}${final_position} ``` -------------------------------- ### Run Tests Script Examples Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud Shell scripts for running AltTester tests, demonstrating both remote and local connection setups for BitBar cloud testing environments. ```shell # Example for remote connection (e.g., iOS VM IP) # This script would typically handle setup, license activation, and test execution. # Set AltTester Server URL ALTTESTER_SERVER_URL="http://:4444" # Activate license (if needed) # /path/to/AltTesterDesktopLinuxBatchmode/AltTester --activate-license # Run tests using AltDriver and connecting to the server # python your_test_script.py --server-url $ALTTESTER_SERVER_URL # Deactivate license (if needed) # /path/to/AltTesterDesktopLinuxBatchmode/AltTester --deactivate-license ``` ```shell # Example for local connection (e.g., Android localhost) # This script would typically handle setup, license activation, and test execution. # Set AltTester Server URL (often localhost for local execution) ALTTESTER_SERVER_URL="http://localhost:4444" # Activate license (if needed) # /path/to/AltTesterDesktopLinuxBatchmode/AltTester --activate-license # Run tests using AltDriver and connecting to the server # python your_test_script.py --server-url $ALTTESTER_SERVER_URL # Deactivate license (if needed) # /path/to/AltTesterDesktopLinuxBatchmode/AltTester --deactivate-license ``` -------------------------------- ### AWS Device Farm Integration Examples Source: https://alttester.com/docs/sdk/latest/home Examples for integrating the AltTester SDK with AWS Device Farm for running tests on Android devices. Provides setup steps for both Python and C# projects, focusing on remote connection usage. ```APIDOC AWS Device Farm Python Project Example: Description: Guide for integrating AltTester SDK with AWS Device Farm using Python. Preparation Steps: Not detailed. Steps for running tests on Android using remote connection: Not detailed. AWS Device Farm C# Project Example: Description: Guide for integrating AltTester SDK with AWS Device Farm using C#. Preparation Steps: Not detailed. Steps for running tests on Android using remote connection: Not detailed. ``` -------------------------------- ### BitBar Integration Examples Source: https://alttester.com/docs/sdk/latest/home Examples for integrating the AltTester SDK with BitBar for running tests. Covers C# project examples for both server-side and client-side execution, including prerequisites and preparation steps. ```APIDOC BitBar C# Project Example (Server-side): Description: Guide for running AltTester SDK tests on BitBar using C# with server-side execution. Prerequisites for running AltTester Server: Not detailed. Preparation Steps: Not detailed. Steps for running the tests: Not detailed. BitBar C# Project Example (Client-side): Description: Guide for running AltTester SDK tests on BitBar using C# with client-side execution. Usage: Not specified in the provided text. ``` -------------------------------- ### Robot Framework Test Case with Keywords Source: https://alttester.com/docs/sdk/latest/pages/get-started A more comprehensive Robot Framework test case example that includes setup and teardown keywords. This demonstrates defining reusable keyword blocks for test execution, such as initializing and stopping the AltDriver. ```robotframework *** Settings*** LibraryAltTesterLibrary Suite SetupSetUp Tests Suite TeardownTeardown Tests *** Test Cases *** Test Resize Panel Load SceneScene 2 Draggable Panel ${alt_object}= Find ObjectNAMEResize Zone ${alt_object_x}= Get Object X ${alt_object} ${alt_object_y}= Get Object Y ${alt_object} ${position_init}= Create List ${alt_object_x} ${alt_object_y} ${screen_position}= Get Screen Position ${alt_object} ${new_x}= Evaluate ${alt_object_x}-200 ${new_y}= Evaluate ${alt_object_y}-200 ${new_screen_position}= Create List ${new_x} ${new_y} Swipe ${screen_position} ${new_screen_position} duration=2 ${alt_object}= Find ObjectNAMEResize Zone ${alt_object_x}= Get Object X ${alt_object} ${alt_object_y}= Get Object Y ${alt_object} ${position_final}= Create List ${alt_object_x} ${alt_object_y} Should Not Be Equal ${position_init} ${position_final} *** Keywords *** SetUp Tests Reverse Port Forwarding Android Initialize Altdriver Teardown Tests Stop Altdriver Remove Reverse Port Forwarding Android ``` -------------------------------- ### BrowserStack Integration Examples Source: https://alttester.com/docs/sdk/latest/home Examples demonstrating how to integrate the AltTester SDK with BrowserStack for running tests on Android and iOS devices, including App Automate and GitHub Actions workflows. Covers prerequisites and setup steps. ```APIDOC BrowserStack App Automate C# Project Example: Description: Setup and execution guide for AltTester SDK with BrowserStack App Automate using C#. Prerequisites: Not detailed. Steps: Not detailed. BrowserStack with GitHub Actions C# Project Example: Description: Guide for integrating AltTester SDK with BrowserStack and GitHub Actions using C#. Local Testing Connection: Uses BrowserStackLocal. Prerequisites: Not detailed. Setup Steps: Not detailed. ``` -------------------------------- ### Tap Example in Robot Framework Source: https://alttester.com/docs/sdk/latest/pages/commands Provides an example of using the Tap command within Robot Framework scripts. It demonstrates finding an object, getting its screen position, performing the tap, and then waiting for a specific UI element. ```Robot Framework Test Tap Coordinates ${capsule_element}=Find Object NAME Capsule ${capsule_element_positions}=Get Screen Position ${capsule_element} Tap ${capsule_element_positions} Wait For Object PATH //CapsuleInfo[@text=Capsule was clicked to jump!] timeout=1 ``` -------------------------------- ### Robot Framework Test Case Example Source: https://alttester.com/docs/sdk/latest/pages/get-started An example Robot Framework test case demonstrating interaction with the AltTester SDK. It includes settings, test case steps, and keywords for finding objects, getting their properties, and performing actions like swiping. ```robotframework *** Settings*** LibraryAltTesterLibrary Suite SetupInitialize Altdriver Suite TeardownStop Altdriver *** Test Cases *** Test Resize Panel Load SceneScene 2 Draggable Panel ${alt_object}= Find ObjectNAMEResize Zone ${alt_object_x}= Get Object X ${alt_object} ${alt_object_y}= Get Object Y ${alt_object} ${position_init}= Create List ${alt_object_x} ${alt_object_y} ${screen_position}= Get Screen Position ${alt_object} ${new_x}= Evaluate ${alt_object_x}-200 ${new_y}= Evaluate ${alt_object_y}-200 ${new_screen_position}= Create List ${new_x} ${new_y} Swipe ${screen_position} ${new_screen_position} duration=2 ${alt_object}= Find ObjectNAMEResize Zone ${alt_object_x}= Get Object X ${alt_object} ${alt_object_y}= Get Object Y ${alt_object} ${position_final}= Create List ${alt_object_x} ${alt_object_y} Should Not Be Equal ${position_init} ${position_final} ``` -------------------------------- ### Configuration File Commands for Test Environment Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud Example YAML commands for a custom test environment configuration file. These commands are used to install applications and run tests, potentially accessing files from an uploaded .zip archive. ```yaml # Example commands for a custom test environment # These commands are written in YAML and used to manage test execution. # They can include steps like installing dependencies or launching AltTester Server. # Example: # - "echo 'Installing dependencies...'" # - "pip install -r requirements.txt" # - "./start_altserver.sh &" # Note: The '&' symbol is used to run commands in the background. ``` -------------------------------- ### GetCurrentScene Examples Source: https://alttester.com/docs/sdk/latest/pages/commands Demonstrates how to get the current scene using the AltTester SDK in various programming languages and a Robot framework. ```C# [Test] publicvoidTestGetCurrentScene() { altDriver.LoadScene("Scene 1 AltDriverTestScene"); Assert.AreEqual("Scene 1 AltDriverTestScene",altDriver.GetCurrentScene()); } ``` ```Java @Test publicvoidtestGetCurrentScene()throwsException { altDriver.loadScene(newAltLoadSceneParams.Builder("Scene 1 AltDriverTestScene").build()); assertEquals("Scene 1 AltDriverTestScene",altDriver.getCurrentScene()); } ``` ```Python deftest_get_current_scene(self): self.alt_driver.load_scene("Scene 1 AltDriverTestScene", True) self.assertEqual("Scene 1 AltDriverTestScene",self.alt_driver.get_current_scene()) ``` ```Robot Test Load And Wait For Scene Load Scene${scene1}${True} Wait For Current Scene To Be${scene1}timeout=1 ${current_scene}=Get Current Scene Should Be Equal${current_scene}${scene1} ``` -------------------------------- ### Robot: WaitForCurrentSceneToBe Example Source: https://alttester.com/docs/sdk/latest/pages/commands Shows a Robot Framework example for waiting for a scene to load. It demonstrates loading a scene and then verifying the current scene using AltTester SDK keywords. ```Robot Test Load And Wait For Scene Load Scene ${scene1} ${True} Wait For Current Scene To Be ${scene1} timeout=1 ${current_scene}= Get Current Scene Should Be Equal ${current_scene} ${scene1} ``` -------------------------------- ### PressKeys Example in C# Source: https://alttester.com/docs/sdk/latest/pages/commands Example of using the PressKeys command in C# to simulate pressing 'K' and 'L' keys simultaneously, then verifying a component property. ```C# [Test] publicvoidTestPressKeys() { AltKeyCode[]keys={AltKeyCode.K,AltKeyCode.L}; altDriver.PressKeys(keys); varaltObject=altDriver.FindObject(By.NAME,"Capsule"); varfinalPropertyValue=altObject.GetComponentProperty("AltExampleScriptCapsule","stringToSetFromTests","Assembly-CSharp"); Assert.AreEqual("multiple keys pressed",finalPropertyValue); } ``` -------------------------------- ### Install Necessary Packages Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud Commands to install required packages for Appium and Selenium WebDriver using the .NET CLI. These packages are essential for test automation. ```bash dotnet add package Appium.WebDriver --version 4.4.0 dotnet add package Selenium.WebDriver --version 3.141.0 ``` -------------------------------- ### PressKeys Example in Python Source: https://alttester.com/docs/sdk/latest/pages/commands Example of using the press_keys command in Python to simulate pressing 'K' and 'L' keys, then finding an object and retrieving its component property. ```Python deftest_press_keys(self): keys = [AltKeyCode.K, AltKeyCode.L] self.alt_driver.press_keys(keys) alt_unity_object = self.alt_driver.find_object(By.NAME, "Capsule") property_value = alt_unity_object.get_component_property( "AltExampleScriptCapsule", "stringToSetFromTests", "Assembly-CSharp" ) assert property_value == "multiple keys pressed" ``` -------------------------------- ### SauceLabs Integration Example Source: https://alttester.com/docs/sdk/latest/home An example showcasing the integration of the AltTester SDK with SauceLabs for running tests on Android and iOS devices using a C# project. Includes prerequisites and execution steps. ```APIDOC SauceLabs C# Project Example: Description: Setup and execution guide for AltTester SDK with SauceLabs using C#. Prerequisites: Not detailed. Steps for running tests on Android and iOS: Not detailed. ``` -------------------------------- ### WaitForObject Examples Source: https://alttester.com/docs/sdk/latest/pages/commands Demonstrates how to use the AltDriver's WaitForObject method in various programming languages to find UI elements by name. ```csharp [Test] public void TestWaitForObject() { const string name = "Capsule"; var altObject = altDriver.WaitForObject(By.NAME, name); } ``` ```java @Test public void testWaitForObject(){ String name = "Capsule"; AltFindObjectsParams altFindObjectsParams = new AltFindObjectsParams.Builder(AltDriver.By.NAME, name).build(); AltWaitForObjectsParams altWaitForObjectsParams = new AltWaitForObjectsParams.Builder( altFindObjectsParams).build(); AltObject altObject = altDriver.waitForObject(altWaitForObjectsParams); } ``` ```python def test_wait_for_object(self): alt_object = self.alt_driver.wait_for_object(By.NAME, "Capsule") ``` ```robotframework Test Wait For Object By Name ${capsule}=Wait For Object NAME Capsule ``` -------------------------------- ### SetServerLogging Example - C# Source: https://alttester.com/docs/sdk/latest/pages/commands Example of how to use the SetServerLogging method in C# to configure server logging levels. It demonstrates setting the logger to File with level Off, and Unity with level Info. ```C# altDriver.SetServerLogging(AltLogger.File,AltLogLevel.Off); altDriver.SetServerLogging(AltLogger.Unity,AltLogLevel.Info); ``` -------------------------------- ### PressKeys Example in Java Source: https://alttester.com/docs/sdk/latest/pages/commands Example of using the pressKeys command in Java with AltPressKeysParams to simulate pressing 'K' and 'L' keys, followed by object finding and property retrieval. ```Java @Test publicvoidtestPressKeys() { AltKeyCode[]keys={AltKeyCode.K,AltKeyCode.L}; altDriver.pressKeys(newAltPressKeysParams.Builder(keys).build()); AltFindObjectsParamsaltFindObjectsParams=newAltFindObjectsParams.Builder( AltDriver.By.NAME,"Capsule").build(); AltObjectaltObject=altDriver.findObject(altFindObjectsParams); AltGetComponentPropertyParamsaltGetComponentPropertyParams=newAltGetComponentPropertyParams.Builder( "AltExampleScriptCapsule", "stringToSetFromTests","Assembly-CSharp").build(); StringfinalPropertyValue=altObject.getComponentProperty(altGetComponentPropertyParams,String.class); assertEquals(finalPropertyValue,"multiple keys pressed"); } ``` -------------------------------- ### Project Setup Commands Source: https://alttester.com/docs/sdk/latest/pages/get-started Commands to create a new NUnit project and add the AltTester-Driver package using the .NET CLI. ```bash dotnet new nunit dotnet add package AltTester-Driver --version x.y.z ``` -------------------------------- ### Press Keys Example in Robot Source: https://alttester.com/docs/sdk/latest/pages/commands Example of using the Press Keys keyword in Robot Framework to simulate pressing 'K' and 'L' keys, then finding an object and getting its component property. ```Robot Test Press Keys ${keys}=Create ListKL Press Keys${keys} ${alt_object}=Find ObjectNAMECapsule ${property_value}=Get Component Property${alt_object}AltExampleScriptCapsulestringToSetFromTestsAssembly-CSharp Should Be Equal As Strings${property_value}multiple keys pressed ``` -------------------------------- ### Robot Framework AltTester Setup and Test Structure Source: https://alttester.com/docs/sdk/latest/pages/get-started Robot Framework test suite structure demonstrating how to import AltTesterLibrary, initialize the AltDriver in the suite setup, and stop it in the suite teardown. Includes a basic test case placeholder. ```robotframework *** Settings*** Library AltTesterLibrary Suite Setup Initialize Altdriver Suite Teardown Stop Altdriver *** Test Cases *** Test My First Test # Test steps go here ``` -------------------------------- ### Wait For Component Property Get Property As String Example Source: https://alttester.com/docs/sdk/latest/pages/commands This example shows how to wait for a Unity UI Canvas object and then retrieve a specific component property ('name') as a string. It highlights waiting for objects and accessing component properties. ```APIDOC Test Wait For Component Property Get Property As String ${Canvas} =Wait For ObjectPATH/Canvas Wait For Component Property${Canvas}UnityEngine.RectTransformnameCanvasUnityEngine.CoreModule1get_property_as_string=${True} ``` -------------------------------- ### Basic AltDriver Test Setup and Execution (C#) Source: https://alttester.com/docs/sdk/latest/pages/get-started Demonstrates initializing the AltDriver, performing actions like loading a scene and tapping UI elements, and asserting object properties using the NUnit testing framework. ```C# using NUnit.Framework; using AltTester.AltTesterSDK.Driver; public class MyFirstTest { private AltDriver altDriver; [OneTimeSetUp] public void SetUp() { altDriver = new AltDriver(); } [OneTimeTearDown] public void TearDown() { altDriver.Stop(); } [Test] public void TestStartGame() { altDriver.LoadScene("Scene 2 Draggable Panel"); altDriver.FindObject(By.NAME, "Close Button").Tap(); altDriver.FindObject(By.NAME, "Button").Tap(); var panelElement = altDriver.WaitForObject(By.NAME, "Panel"); Assert.IsTrue(panelElement.enabled); } } ``` -------------------------------- ### Robot Framework Test Setup/Teardown Source: https://alttester.com/docs/sdk/latest/pages/advanced-usage Example of setting up and tearing down the AltTester environment using Robot Framework. It includes keywords for initializing the driver, establishing port forwarding, and stopping the driver with cleanup. ```Robot Framework *** Settings *** Library AltTesterLibrary Suite Setup SetUp Tests Suite Teardown Teardown Tests *** Test Cases *** Test Resize Panel Load Scene Scene 2 Draggable Panel ${alt_object}= Find Object NAME=Resize Zone ${alt_object_x}= Get Object X ${alt_object} ${alt_object_y}= Get Object Y ${alt_object} ${position_init}= Create List ${alt_object_x} ${alt_object_y} ${screen_position}= Get Screen Position ${alt_object} ${new_x}= Evaluate ${alt_object_x}-200 ${new_y}= Evaluate ${alt_object_y}-200 ${new_screen_position}= Create List ${new_x} ${new_y} Swipe ${screen_position} ${new_screen_position} duration=2 ${alt_object}= Find Object NAME=Resize Zone ${alt_object_x}= Get Object X ${alt_object} ${alt_object_y}= Get Object Y ${alt_object} ${position_final}= Create List ${alt_object_x} ${alt_object_y} Should Not Be Equal ${position_init} ${position_final} *** Keywords *** SetUp Tests Reverse Port Forwarding Android Initialize Altdriver Teardown Tests Stop Altdriver Remove Reverse Port Forwarding Android ``` -------------------------------- ### AltReversePortForwarding Android Setup (Java) Source: https://alttester.com/docs/sdk/latest/pages/advanced-usage Illustrates the usage of static methods from the AltReversePortForwarding class in Java for configuring reverse port forwarding on Android. Provides a complete example test file demonstrating setup, interaction with UI elements, and teardown. ```java import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import com.alttester.AltReversePortForwarding; import com.alttester.AltDriver; import com.alttester.AltObject; import com.alttester.Commands.FindObject.AltFindObjectsParameters; import com.alttester.Commands.FindObject.AltWaitForObjectsParameters; import java.io.IOException; public class MyFirstTest{ private static AltDriver altDriver; @BeforeClass public static void setUp() throws IOException { AltReversePortForwarding.reversePortForwardingAndroid(); altDriver = new AltDriver(); } @AfterClass public static void tearDown() throws Exception { altDriver.stop(); AltReversePortForwarding.removeReversePortForwardingAndroid(); } @Test public void openClosePanelTest(){ altDriver.loadScene(new AltLoadSceneParams.Builder("Scene 2 Draggable Panel").build()); AltFindObjectsParamsaltFindObjectsParametersCamera = new AltFindObjectsParams.Builder( AltDriver.By.PATH, "//Main Camera") .build(); AltObject camera = altDriver.findObject(altFindObjectsParametersCamera); AltFindObjectsParamscloseButtonObjectsParameters = new AltFindObjectsParams.Builder( AltDriver.By.NAME, "Close Button") .withCamera(AltDriver.By.ID, String.valueOf(camera.id)) .build(); altDriver.findObject(closeButtonObjectsParameters).tap(); AltFindObjectsParamsbuttonObjectsParameters = new AltFindObjectsParams.Builder( AltDriver.By.NAME, "Button") .withCamera(AltDriver.By.ID, String.valueOf(camera.id)) .build(); altDriver.findObject(buttonObjectsParameters).tap(); AltFindObjectsParamspanelObjectsParameters = new AltFindObjectsParams.Builder( AltDriver.By.NAME, "Panel") .withCamera(AltDriver.By.ID, String.valueOf(camera.id)) .build(); AltWaitForObjectsParamspanelWaitForObjectsParameters = new AltWaitForObjectsParams.Builder( panelObjectsParameters).build(); AltObject panelElement = altDriver.waitForObject(panelWaitForObjectsParameters); Assertions.assertTrue(panelElement.isEnabled()); } } ``` -------------------------------- ### Java: Basic AltTester Setup and Test Execution Source: https://alttester.com/docs/sdk/latest/pages/get-started Demonstrates a complete JUnit test class using AltDriver. It covers setting up the AltDriver, loading a scene, finding objects by path and name, performing tap actions, waiting for objects, and asserting element states. This snippet is suitable for understanding the core workflow of AltTester in Java. ```Java import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import com.alttester.AltReversePortForwarding; import com.alttester.AltDriver; import com.alttester.AltObject; import com.alttester.Commands.FindObject.AltFindObjectsParameters; import com.alttester.Commands.FindObject.AltWaitForObjectsParameters; import java.io.IOException; public class MyFirstTest { private static AltDriver altDriver; @BeforeClass public static void setUp() throws IOException { AltReversePortForwarding.reversePortForwardingAndroid(); altDriver = new AltDriver(); } @AfterClass public static void tearDown() throws Exception { altDriver.stop(); AltReversePortForwarding.removeReversePortForwardingAndroid(); } @Test public void openClosePanelTest() { altDriver.loadScene(new AltLoadSceneParams.Builder("Scene 2 Draggable Panel").build()); AltFindObjectsParameters altFindObjectsParametersCamera = new AltFindObjectsParameters.Builder( AltDriver.By.PATH, "//Main Camera" ).build(); AltObject camera = altDriver.findObject(altFindObjectsParametersCamera); AltFindObjectsParameters closeButtonObjectsParameters = new AltFindObjectsParameters.Builder( AltDriver.By.NAME, "Close Button" ).withCamera(AltDriver.By.ID, String.valueOf(camera.id)) .build(); altDriver.findObject(closeButtonObjectsParameters).tap(); AltFindObjectsParameters buttonObjectsParameters = new AltFindObjectsParameters.Builder( AltDriver.By.NAME, "Button" ).withCamera(AltDriver.By.ID, String.valueOf(camera.id)) .build(); altDriver.findObject(buttonObjectsParameters).tap(); AltFindObjectsParameters panelObjectsParameters = new AltFindObjectsParameters.Builder( AltDriver.By.NAME, "Panel" ).withCamera(AltDriver.By.ID, String.valueOf(camera.id)) .build(); AltWaitForObjectsParameters panelWaitForObjectsParameters = new AltWaitForObjectsParameters.Builder( panelObjectsParameters ).build(); AltObject panelElement = altDriver.waitForObject(panelWaitForObjectsParameters); Assert.assertTrue(panelElement.isEnabled()); } } ``` -------------------------------- ### LoadScene Examples Source: https://alttester.com/docs/sdk/latest/pages/commands Illustrates how to load scenes using the AltTester SDK in C#, Java, Python, and a Robot framework, including parameter usage. ```C# [Test] publicvoidTestGetCurrentScene() { altDriver.LoadScene("Scene 1 AltDriverTestScene",true); Assert.AreEqual("Scene 1 AltDriverTestScene",altDriver.GetCurrentScene()); } ``` ```Java @Test publicvoidtestGetCurrentScene() { altDriver.loadScene(newAltLoadSceneParams.Builder("Scene 1 AltDriverTestScene").build()); assertEquals("Scene 1 AltDriverTestScene",altDriver.getCurrentScene()); } ``` ```Python deftest_get_current_scene(self): self.alt_driver.load_scene("Scene 1 AltDriverTestScene", True) self.assertEqual("Scene 1 AltDriverTestScene",self.alt_driver.get_current_scene()) ``` ```Robot Test Load And Wait For Scene Load Scene${scene1}${True} Wait For Current Scene To Be${scene1}timeout=1 ${current_scene}=Get Current Scene Should Be Equal${current_scene}${scene1} ``` -------------------------------- ### Prepare run-tests.sh for AltTester Linux Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud This section refers to the `run-tests.sh` script used in the preparation steps for local connections on an Ubuntu VM. It indicates that commands for installing and launching the AltTesterĀ® Desktop Linux build in batch mode should be included within this script. ```bash # Commands to install and launch AltTesterĀ® Desktop Linux build in batch mode # should be added here within the run-tests.sh script. ``` -------------------------------- ### Python AltDriver with Android Port Forwarding Source: https://alttester.com/docs/sdk/latest/pages/get-started Example Python test demonstrating AltDriver usage with Android-specific reverse port forwarding for establishing a connection. Includes setup and teardown for port forwarding. ```python import unittest from alttester import AltDriver, By, AltReversePortForwarding class MyFirstTest(unittest.TestCase): alt_driver = None @classmethod def setUpClass(cls): AltReversePortForwarding.reverse_port_forwarding_android() cls.alt_driver = AltDriver() @classmethod def tearDownClass(cls): cls.alt_driver.stop() AltReversePortForwarding.remove_reverse_port_forwarding_android() def test_open_close_panel(self): self.alt_driver.load_scene("Scene 2 Draggable Panel") self.alt_driver.find_object(By.NAME, "Close Button").tap() self.alt_driver.find_object(By.NAME, "Button").tap() panel_element = self.alt_driver.wait_for_object(By.NAME, "Panel") self.assertTrue(panel_element.enabled) ``` -------------------------------- ### Appium Setup with Capabilities Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-appium Conceptual Python code snippet illustrating the setup of an Appium driver, focusing on capabilities. This demonstrates the modern approach using Options, as recommended for Selenium 4 and later, replacing the deprecated DesiredCapabilities. ```Python from appium import webdriver from selenium.webdriver.chrome.options import Options as ChromeOptions from selenium.webdriver.firefox.options import Options as FirefoxOptions # Example for Android android_caps = { 'platformName': 'Android', 'platformVersion': '10', 'deviceName': 'Android Emulator', 'app': '/path/to/your/app.apk', 'automationName': 'UiAutomator2' } # For Selenium 4+, use Options instead of DesiredCapabilities # Example using ChromeOptions (if Appium server is configured for Chrome) # chrome_options = ChromeOptions() # chrome_options.add_experimental_option("detach", True) # Example for Appium driver initialization (conceptual) # driver = webdriver.Remote('http://localhost:4723/wd/hub', android_caps) # Note: The actual driver creation and capability setting will depend on the specific Appium setup and test framework used. # The text emphasizes the shift from DesiredCapabilities to Options for passing capabilities in modern Selenium versions. ``` -------------------------------- ### Tap Example in C# Source: https://alttester.com/docs/sdk/latest/pages/commands Demonstrates how to use the Tap command in C# to tap on a UI element identified by its name. It includes finding the object, getting its screen position, performing the tap, and waiting for a subsequent UI change. ```C# [Test] public void TestTapCoordinates() { const string name = "UIButton"; var altObject = altDriver.FindObject(By.NAME, name); altDriver.Tap(altObject.GetScreenPosition()); Assert.AreEqual(name, altObject.name); altDriver.WaitForObject(By.PATH, "//CapsuleInfo[@text=\"UIButtonclickedtojumpcapsule!\"]"); } ``` -------------------------------- ### Simulate Key Down and Key Up - Java Example Source: https://alttester.com/docs/sdk/latest/pages/commands Provides a Java example for simulating key presses using KeyDown and KeyUp. It includes setting up parameters, executing the commands, and asserting the results by finding UI elements that report the key events. ```Java @Test publicvoidTestKeyDownAndKeyUp()throwsException{ AltFindObjectsParamsaltFindObjectsParameters1=newAltFindObjectsParams.Builder( AltDriver.By.NAME,"LastKeyDownValue").build(); AltFindObjectsParamsaltFindObjectsParameters2=newAltFindObjectsParams.Builder( AltDriver.By.NAME,"LastKeyUpValue").build(); AltFindObjectsParamsaltFindObjectsParameters3=newAltFindObjectsParams.Builder( AltDriver.By.NAME,"LastKeyPressedValue").build(); AltKeyCodekcode=AltKeyCode.A; AltKeyParamsaltKeyParams=newAltKeyParams.Builder(kcode).build(); altDriver.keyDown(altKeyParams); Thread.sleep(2000); AltObjectlastKeyDown=altDriver.findObject(altFindObjectsParameters1); AltObjectlastKeyPress=altDriver.findObject(altFindObjectsParameters3); assertEquals("A",AltKeyCode.valueOf(lastKeyDown.getText()).name()); assertEquals("A",AltKeyCode.valueOf(lastKeyPress.getText()).name()); altDriver.keyUp(kcode); Thread.sleep(2000); AltObjectlastKeyUp=altDriver.findObject(altFindObjectsParameters2); assertEquals("A",AltKeyCode.valueOf(lastKeyUp.getText()).name()); } ``` -------------------------------- ### Python Test Setup/Teardown Source: https://alttester.com/docs/sdk/latest/pages/advanced-usage Example of how to set up and tear down the AltDriver and reverse port forwarding within a Python unittest class. It demonstrates calling static methods for port forwarding and initializing the AltDriver. ```Python import unittest from alttester import AltDriver, AltReversePortForwarding class MyFirstTest(unittest.TestCase): alt_driver = None @classmethod def setUpClass(cls): AltReversePortForwarding.reverse_port_forwarding_android() cls.alt_driver = AltDriver() @classmethod def tearDownClass(cls): cls.alt_driver.stop() AltReversePortForwarding.remove_reverse_port_forwarding_android() def test_open_close_panel(self): self.alt_driver.load_scene("Scene 2 Draggable Panel") self.alt_driver.find_object(By.NAME, "Close Button").tap() self.alt_driver.find_object(By.NAME, "Button").tap() panel_element = self.alt_driver.wait_for_object(By.NAME, "Panel") self.assertTrue(panel_element.enabled) ``` -------------------------------- ### Run Pytest Concurrently with Platform Argument Source: https://alttester.com/docs/sdk/latest/pages/advanced-usage Configures pytest to run tests concurrently across different platforms by passing a platform argument. Includes setup in the test file and conftest.py, along with command-line execution examples. ```Python def test(platform): alt_driver = AltDriver(host="127.0.0.1", port=13000, platform=platform) ``` ```Python def pytest_addoption(parser): parser.addoption("--platform", action="store", default="default name") def pytest_generate_tests(metafunc): option_value = metafunc.config.option.platform if 'platform' in metafunc.fixturenames and option_value is not None: metafunc.parametrize("platform", [option_value]) ``` ```pytest command "WindowsPlayer"& pytest "Android" ``` -------------------------------- ### Robot Framework PointerEnter/Exit Example Source: https://alttester.com/docs/sdk/latest/pages/commands Shows how to simulate pointer enter and exit actions on a UI element using Robot Framework with the AltTester library. It includes steps to get and compare component properties like highlight color. ```Robot Framework Test Pointer Enter And Exit ${alt_object}=Find ObjectNAMEDrop Image ${color1}=Get Component Property${alt_object}AltExampleScriptDropMehighlightColorAssembly-CSharp Pointer Enter${alt_object} ${color2}=Get Component Property${alt_object}AltExampleScriptDropMehighlightColorAssembly-CSharp ${color1_r}=Get Percent From Specific Color${color1}r ${color1_g}=Get Percent From Specific Color${color1}g ${color1_b}=Get Percent From Specific Color${color1}b ${color1_a}=Get Percent From Specific Color${color1}a ${color2_r}=Get Percent From Specific Color${color2}r ${color2_g}=Get Percent From Specific Color${color2}g ${color2_b}=Get Percent From Specific Color${color2}b ${color2_a}=Get Percent From Specific Color${color2}a Evaluate${color1_r}!=${color2_r} or ${color1_g}!=${color2_g} or ${color1_b}!=${color2_b} or ${color1_a}!=${color2_a} Pointer Exit${alt_object} ${color3}=Get Component Property${alt_object}AltExampleScriptDropMehighlightColorAssembly-CSharp ${color3_r}=Get Percent From Specific Color${color3}r ${color3_g}=Get Percent From Specific Color${color3}g ${color3_b}=Get Percent From Specific Color${color3}b ${color3_a}=Get Percent From Specific Color${color3}a Evaluate${color3_r}!=${color2_r} or ${color3_g}!=${color2_g} or ${color3_b}!=${color2_b} or ${color3_a}!=${color2_a} Evaluate${color1_r}!=${color3_r} or ${color1_g}!=${color3_g} or ${color1_b}!=${color3_b} or ${color1_a}!=${color3_a} ``` -------------------------------- ### Running Robot Framework Tests Source: https://alttester.com/docs/sdk/latest/pages/get-started Demonstrates how to execute Robot Framework test suites using the 'robot' command. This includes running a single test file or an entire directory of tests. ```bash robot my_first_test.robot ``` ```bash robot path/to/my_tests/ ``` -------------------------------- ### AWS Device Farm Test Run Configuration Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud Guides through configuring a test run within AWS Device Farm for Android applications instrumented with AltTesterĀ® Unity SDK. It specifies the selection of test frameworks and custom environment setups. ```APIDOC AWS Device Farm Test Run Setup: 1. **Project Creation**: Create a new project in AWS Device Farm (`Mobile Device Testing` > `Projects`). 2. **New Run Creation**: Select `Create a new run`. 3. **App Upload**: Add the instrumented application build under the `Mobile App` tab. 4. **Test Framework Selection**: * Choose `Appium Ruby` as the Test Framework. This is recommended due to stricter validation on other frameworks like C#. * Upload the test suite as a **.zip** file. 5. **Custom Environment Configuration**: * Select `Run your test in a custom environment`. * Edit the default YAML file to include necessary commands for test environment setup and execution. 6. **Device Selection**: Choose devices for test execution from available device pools or recommended top devices. 7. **Device State Configuration**: No specific changes are required for the device state in this example. 8. **Execution Timeout**: Set the execution timeout for devices. 9. **Start Tests**: Initiate the test execution. 10. **Result Monitoring**: Monitor test execution progress and view detailed logs and video recordings on the project screen. ``` -------------------------------- ### AltTester Desktop Download Links Source: https://alttester.com/docs/sdk/latest/pages/alttester-with-cloud Provides direct download links for AltTester Desktop packages for various operating systems, essential for setting up cloud testing environments, especially for iOS where reverse proxying is not supported. ```APIDOC AltTester Desktop Packages: macOS: URL: https://alttester.com/app/uploads/AltTester/desktop/AltTesterDesktopPackageMac__v2.2.4.zip Windows: URL: https://alttester.com/app/uploads/AltTester/desktop/AltTesterDesktopPackageWindows__v2.2.4.zip Linux (Batchmode): URL: https://alttester.com/app/uploads/AltTester/desktop/AltTesterDesktopLinuxBatchmode.zip ``` -------------------------------- ### C# Test Example with AltDriver and NUnit (Reverse Port Forwarding) Source: https://alttester.com/docs/sdk/latest/pages/get-started An advanced C# test case using NUnit and AltDriver, including setup for reverse port forwarding for Android connections. This ensures the AltTester Desktop can communicate with the Android device. ```csharp usingAltTester.AltTesterSDK.Driver; usingAltTester.AltTesterSDK.Driver.AltReversePortForwarding; usingNUnit.Framework; publicclassMyFirstTest { privateAltDriveraltDriver; [OneTimeSetUp] publicvoidSetUp() { AltReversePortForwarding.ReversePortForwardingAndroid(); altDriver=newAltDriver(); } [OneTimeTearDown] publicvoidTearDown() { altDriver.Stop(); AltReversePortForwarding.RemoveReversePortForwardingAndroid(); } [Test] publicvoidTestStartGame() { altDriver.LoadScene("Scene 2 Draggable Panel"); altDriver.FindObject(By.NAME,"Close Button").Tap(); altDriver.FindObject(By.NAME,"Button").Tap(); varpanelElement=altDriver.WaitForObject(By.NAME,"Panel"); Assert.IsTrue(panelElement.enabled); } } ``` -------------------------------- ### AltTester Lean Touch Integration Steps Source: https://alttester.com/docs/sdk/latest/pages/faq-troubleshooting Instructions for integrating AltTester with applications using Lean Touch and the Old Input System. This involves adding an assembly definition reference and modifying input handling. ```C# 1. Add `AltTesterUnitySDK` as an assembly definition reference in `CW.Common` asmdef. 2. In the `CwInput.cs` file replace every occurrence of `UnityEngine.Input.` with `Input.` ```