Skip to content

Commit fb0aa7c

Browse files
committed
Support set_power_capacity
1 parent 84eab6d commit fb0aa7c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from selenium import webdriver
16+
from ..mobilecommand import MobileCommand as Command
17+
18+
19+
class Power(webdriver.Remote):
20+
21+
def set_power_capacity(self, percent):
22+
"""Emulate power capacity change on the connected emulator.
23+
24+
:Args:
25+
- percent: The power capacity to be set
26+
27+
:Usage:
28+
self.driver.set_power_capacity(50)
29+
"""
30+
self.execute(Command.SET_POWER_CAPACITY, {'percent': percent})
31+
32+
def _addCommands(self):
33+
self.command_executor._commands[Command.SET_POWER_CAPACITY] = \
34+
('POST', '/session/$sessionId/appium/device/power_capacity')

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ class MobileCommand(object):
7777
COMPARE_IMAGES = 'compareImages'
7878
FINGER_PRINT = 'fingerPrint'
7979
SEND_SMS = 'sendSms'
80+
SET_POWER_CAPACITY = 'setPowerCapacity'

appium/webdriver/webdriver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .extensions.hw_actions import HardwareActions
3939
from .extensions.location import Location
4040
from .extensions.network import Network
41+
from .extensions.power import Power
4142
from .extensions.remote_fs import RemoteFS
4243
from .extensions.screen_record import ScreenRecord
4344
from .extensions.search_context import AppiumSearchContext
@@ -117,6 +118,7 @@ class WebDriver(
117118
Keyboard,
118119
Location,
119120
Network,
121+
Power,
120122
RemoteFS,
121123
ScreenRecord,
122124
Settings,

0 commit comments

Comments
 (0)