package net.northking.cctp.element.mobile.thread;

import io.appium.java_client.AppiumDriver;
import net.northking.cctp.element.core.DeviceDriver;
import net.northking.cctp.element.core.exception.ExecuteException;
import net.northking.cctp.element.mobile.utils.phoneUtils.FunctionKeyUtil;
import org.openqa.selenium.WebElement;

import java.util.concurrent.Callable;

public class PressKeyBackThread implements Callable<Boolean> {

    private DeviceDriver deviceDriver;

    public PressKeyBackThread(DeviceDriver deviceDriver) {
        this.deviceDriver = deviceDriver;
    }

    @Override
    public Boolean call() throws Exception {
        try {
            AppiumDriver<WebElement> driver = (AppiumDriver<WebElement>) deviceDriver;
            FunctionKeyUtil.pressKeyBack(driver);
        } catch (Exception e) {
            throw new ExecuteException("点击返回健失败");
        }
        return true;
    }
}
