File tree Expand file tree Collapse file tree 4 files changed +71
-1
lines changed
test/unit/webdriver/device Expand file tree Collapse file tree 4 files changed +71
-1
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
+
17
+ from appium .webdriver .mobilecommand import MobileCommand as Command
18
+
19
+
20
+ class Display (webdriver .Remote ):
21
+
22
+ def get_display_density (self ):
23
+ """Get the display density, Android only
24
+
25
+ :Returns:
26
+ int: The display density of the Android device(dpi)
27
+
28
+ :Usage:
29
+ self.driver.get_display_density()
30
+ """
31
+ return self .execute (Command .GET_DISPLAY_DENSITY )['value' ]
32
+
33
+ # pylint: disable=protected-access
34
+
35
+ def _addCommands (self ):
36
+ self .command_executor ._commands [Command .GET_DISPLAY_DENSITY ] = \
37
+ ('GET' , '/session/$sessionId/appium/device/display_density' )
Original file line number Diff line number Diff line change @@ -78,20 +78,21 @@ class MobileCommand(object):
78
78
GET_CURRENT_ACTIVITY = 'getCurrentActivity'
79
79
GET_CURRENT_PACKAGE = 'getCurrentPackage'
80
80
GET_SYSTEM_BARS = 'getSystemBars'
81
+ GET_DISPLAY_DENSITY = 'getDisplayDensity'
81
82
TOGGLE_WIFI = 'toggleWiFi'
82
83
TOGGLE_LOCATION_SERVICES = 'toggleLocationServices'
83
84
END_TEST_COVERAGE = 'endTestCoverage'
84
85
GET_PERFORMANCE_DATA_TYPES = 'getPerformanceDataTypes'
85
86
GET_PERFORMANCE_DATA = 'getPerformanceData'
86
87
GET_NETWORK_CONNECTION = 'getNetworkConnection'
87
88
SET_NETWORK_CONNECTION = 'setNetworkConnection'
88
- SET_NETWORK_SPEED = 'setNetworkSpeed'
89
89
90
90
# Android Emulator
91
91
SEND_SMS = 'sendSms'
92
92
MAKE_GSM_CALL = 'makeGsmCall'
93
93
SET_GSM_SIGNAL = 'setGsmSignal'
94
94
SET_GSM_VOICE = 'setGsmVoice'
95
+ SET_NETWORK_SPEED = 'setNetworkSpeed'
95
96
SET_POWER_CAPACITY = 'setPowerCapacity'
96
97
SET_POWER_AC = 'setPowerAc'
97
98
Original file line number Diff line number Diff line change 29
29
from .errorhandler import MobileErrorHandler
30
30
from .extensions .action_helpers import ActionHelpers
31
31
from .extensions .android .activities import Activities
32
+ from .extensions .android .display import Display
32
33
from .extensions .android .gsm import Gsm
33
34
from .extensions .android .network import Network
34
35
from .extensions .android .performance import Performance
@@ -114,6 +115,7 @@ class WebDriver(
114
115
Clipboard ,
115
116
Context ,
116
117
DeviceTime ,
118
+ Display ,
117
119
Gsm ,
118
120
HardwareActions ,
119
121
ImagesComparison ,
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 test .unit .helper .test_helper import android_w3c_driver , appium_command
16
+
17
+ import httpretty
18
+
19
+
20
+ class TestWebDriverDisplay (object ):
21
+
22
+ @httpretty .activate
23
+ def test_get_display_density (self ):
24
+ driver = android_w3c_driver ()
25
+ httpretty .register_uri (
26
+ httpretty .GET ,
27
+ appium_command ('/session/1234567890/appium/device/display_density' ),
28
+ body = '{"value": 560}'
29
+ )
30
+ assert driver .get_display_density () == 560
You can’t perform that action at this time.
0 commit comments