File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 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' )
Original file line number Diff line number Diff 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'
Original file line number Diff line number Diff line change 3838from .extensions .hw_actions import HardwareActions
3939from .extensions .location import Location
4040from .extensions .network import Network
41+ from .extensions .power import Power
4142from .extensions .remote_fs import RemoteFS
4243from .extensions .screen_record import ScreenRecord
4344from .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 ,
You can’t perform that action at this time.
0 commit comments