Appium Concepts: Appium command-to Fetch/Get “RemoteAddress” for both iOS & Android
.getRemoteAddress()

Please go through the below video for complete details:
Topic: Command — .getRemoteAddress()
Usage: To Fetch remote address (i.e. host ip address & port) details
Command:
//Get Appium Server Remote Address
URL url=driver.getRemoteAddress();
Return Type: URL
Java Code:
package com.appiumguide.appiumconcepts;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.options.UiAutomator2Options;
import java.net.*;
import java.time.Duration;
/**
* Script Details - Appium Concepts | Appium command-To Get “RemoteAddress” for both iOS & Android
*
* appium-java-client version: 9.3.0
*
* @author 'Ramesh Kodumuru' for AppiumGuide [appiumguide@gmail.com]
*/
public class GetRemoteAddressDemo {
private AndroidDriver driver;
@BeforeTest
public void setup() throws MalformedURLException {
UiAutomator2Options cap=new UiAutomator2Options();
cap.setPlatformName("android");
cap.setAutomationName("uiautomator2");
cap.setDeviceName("Pixel8Pro");
driver = new AndroidDriver(new URL("http://127.0.0.1:10000"), cap);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(100));
}
@Test
public void test() throws InterruptedException {
//Get Appium Server Remote Address
URL url=driver.getRemoteAddress();
System.out.println("Appium Server Remote Address - "+url);
}
@AfterTest
public void teardown() {
if(driver!=null) {
//driver.quit();
}
}
}
Output:

GitHub Link:
No comments:
Post a Comment