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

pickleib.mobile.driver.ServiceFactory Maven / Gradle / Ivy

The newest version!
package pickleib.mobile.driver;

import context.ContextStore;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import utils.Printer;

import java.time.Duration;

import static utils.StringUtilities.Color.*;

public class ServiceFactory {
    static Printer log = new Printer(ServiceFactory.class);

    public static AppiumDriverLocalService service;
    static String address;
    static Integer port;

    public static void startService(String address, Integer port){
        log.info("Starting service on " + PURPLE.getValue() + address + ":" + port + RESET.getValue());
        ServiceFactory.address = address;
        ServiceFactory.port = port;
        service = new AppiumServiceBuilder()
                .withIPAddress(address)
                .usingPort(port)
                .withTimeout(Duration.ofSeconds(Integer.parseInt(ContextStore.get("appium-server-launch-timeout", "45"))))
                .build();
        if(!Boolean.parseBoolean(ContextStore.get("detailed-logging", "false")))
            ServiceFactory.service.clearOutPutStreams();
        service.start();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy