Add battery information accessors by mykola-mokhnach · Pull Request #882 · appium/java-client

Expand Up @@ -18,13 +18,17 @@
import static io.appium.java_client.MobileCommand.RUN_APP_IN_BACKGROUND; import static io.appium.java_client.MobileCommand.prepareArguments; import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT;
import com.google.common.collect.ImmutableMap;
import io.appium.java_client.AppiumDriver; import io.appium.java_client.FindsByIosClassChain; import io.appium.java_client.FindsByIosNSPredicate; import io.appium.java_client.FindsByIosUIAutomation; import io.appium.java_client.HidesKeyboardWithKeyName; import io.appium.java_client.LocksDevice; import io.appium.java_client.battery.HasBattery; import io.appium.java_client.remote.MobilePlatform; import io.appium.java_client.screenrecording.CanRecordScreen; import io.appium.java_client.service.local.AppiumDriverLocalService; Expand All @@ -39,6 +43,8 @@
import java.net.URL; import java.time.Duration; import java.util.Collections; import java.util.Map;
/** * iOS driver implementation. Expand All @@ -56,7 +62,8 @@ public class IOSDriver<T extends WebElement> extends AppiumDriver<T> implements HidesKeyboardWithKeyName, ShakesDevice, HasIOSSettings, FindsByIosUIAutomation<T>, LocksDevice, PerformsTouchID, FindsByIosNSPredicate<T>, FindsByIosClassChain<T>, PushesFiles, CanRecordScreen, HasIOSClipboard, ListensToSyslogMessages { FindsByIosClassChain<T>, PushesFiles, CanRecordScreen, HasIOSClipboard, ListensToSyslogMessages, HasBattery<IOSBatteryInfo> {
private static final String IOS_PLATFORM = MobilePlatform.IOS;
Expand Down Expand Up @@ -177,6 +184,13 @@ public IOSDriver(Capabilities desiredCapabilities) { return new InnerTargetLocator(); }
@SuppressWarnings("unchecked") @Override public IOSBatteryInfo getBatteryInfo() { return new IOSBatteryInfo((Map<String, Object>) execute(EXECUTE_SCRIPT, ImmutableMap.of( "script", "mobile: batteryInfo", "args", Collections.emptyList()))); }
private class InnerTargetLocator extends RemoteTargetLocator { @Override public Alert alert() { return new IOSAlert(super.alert()); Expand Down