All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.appium.device.Devices Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
package com.appium.device;

import com.appium.manager.AppiumServerManager;
import com.appium.utils.Api;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;

import java.net.URL;
import java.util.Arrays;
import java.util.List;

public class Devices {
    private static List instance;

    private Devices() {

    }

    @SneakyThrows
    public static List getConnectedDevices() {
        if (instance == null) {
            System.out.println(Thread.currentThread().getId());
            AppiumServerManager appiumServerManager = new AppiumServerManager();
            String remoteWDHubIP = appiumServerManager.getRemoteWDHubIP();
            URL url = new URL(remoteWDHubIP);
            String response = new Api().getResponse(url.getProtocol()
                    + "://" + url.getHost() + ":" + url.getPort() + "/device-farm/api/device");
            instance =  Arrays.asList(new ObjectMapper().readValue(response, Device[].class));
        }
        return instance;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy