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 PressKeyMenuThread implements Callable<Boolean> {

    private DeviceDriver deviceDriver;

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

    @Override
    public Boolean call() throws Exception {
        try {
            AppiumDriver<WebElement> driver = (AppiumDriver<WebElement>) deviceDriver;
            FunctionKeyUtil.pressKeyMenu(driver);
        } catch (Exception e) {
            throw new ExecuteException("点击多任务键失败");
        }
        return true;
    }
}
