Integrating Custom Appium Code & Scriptless

You are here:
< All Topics

Appium Custom Scripts

Appium Custom Scripts writing in TestGrid Automation Testing tool

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

add custom script  in TestGrid Automation Testing tool

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

Actions

Call Custom Script

    • 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.

Android Appium Custom Script:

    • For Android we can write custom scripts in Java using Appium framework.
    • We can use the “driver” object to access all methods of WebDriver class.
    • Following are some examples:
Sample 1
MobileElement passwordEditText = driver.findElement(By.xpath("//android.widget.EditText[@text='Password']"));
passwordEditText.sendKeys("test@123");
Sample 2
MobileElement signInButton = driver.findElement(By.xpath("//android.widget.Button[@text='Sign In']"));
signInButton.click();
Sample 3
WebElement ele1 = (WebElement) driver.findElementsById("com.mobeta.android.demodslv:id/drag_handle").get(2);

WebElement ele2 = (WebElement) driver.findElementsById("com.mobeta.android.demodslv:id/drag_handle").get(5);

TouchAction action = new TouchAction((MobileDriver) driver);
  
System.out.println("It Is dragging element.");

action.longPress(ele1).moveTo(ele2).release().perform();

iOS Appium Custom Script

    • For iOS we can write custom scripts in Java using Appium framework.
    • We can use the “driver” object to access all methods of WebDriver class.
    • Following are some examples:
Sample 1
MobileElement passwordEditText = driver.findElement(By.xpath("//XCUIElementTypeTextView[@name=’LocationTextView’]"));
passwordEditText.sendKeys("test@123");
Sample 2
MobileElement signInButton = driver.findElement(By.xpath("//XCUIElementTypeButton[@name=’Start updating’]"));
signInButton.click();
Sample 3
WebElement ele1 = (WebElement) driver.findElementByAccessibilityId("drag_handle1");

WebElement ele2 = (WebElement) driver.findElementByAccessibilityId("drag_handle2");

TouchAction action = new TouchAction((MobileDriver) driver);

System.out.println("It Is dragging element.");

action.longPress(ele1).moveTo(ele2).release().perform();
Table of Contents