Skip to content

Commit 42b4dca

Browse files
authored
Fix missing package, missing commands and a test (appium#296)
* add extensions into package * add tests for context to make sure it loads * move command definition from extensions to root
1 parent 10dcab9 commit 42b4dca

5 files changed

Lines changed: 47 additions & 22 deletions

File tree

appium/webdriver/extensions/context.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,3 @@ def context(self):
4646
driver.context
4747
"""
4848
return self.current_context
49-
50-
# pylint: disable=protected-access
51-
52-
def _addCommands(self):
53-
self.command_executor._commands[Command.CONTEXTS] = \
54-
('GET', '/session/$sessionId/contexts')
55-
self.command_executor._commands[Command.GET_CURRENT_CONTEXT] = \
56-
('GET', '/session/$sessionId/context')
57-
self.command_executor._commands[Command.SWITCH_TO_CONTEXT] = \
58-
('POST', '/session/$sessionId/context')

appium/webdriver/extensions/location.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,3 @@ def location(self):
5252
- altitude
5353
"""
5454
return self.execute(Command.GET_LOCATION)['value']
55-
56-
# pylint: disable=protected-access
57-
58-
def _addCommands(self):
59-
self.command_executor._commands[Command.TOGGLE_LOCATION_SERVICES] = \
60-
('POST', '/session/$sessionId/appium/device/toggle_location_services')
61-
self.command_executor._commands[Command.GET_LOCATION] = \
62-
('GET', '/session/$sessionId/location')
63-
self.command_executor._commands[Command.SET_LOCATION] = \
64-
('POST', '/session/$sessionId/location')

appium/webdriver/webdriver.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,20 @@ def finger_print(self, finger_id):
14121412
# pylint: disable=protected-access
14131413

14141414
def _addCommands(self):
1415-
super(WebDriver, self)._addCommands()
1415+
self.command_executor._commands[Command.CONTEXTS] = \
1416+
('GET', '/session/$sessionId/contexts')
1417+
self.command_executor._commands[Command.GET_CURRENT_CONTEXT] = \
1418+
('GET', '/session/$sessionId/context')
1419+
self.command_executor._commands[Command.SWITCH_TO_CONTEXT] = \
1420+
('POST', '/session/$sessionId/context')
1421+
1422+
self.command_executor._commands[Command.TOGGLE_LOCATION_SERVICES] = \
1423+
('POST', '/session/$sessionId/appium/device/toggle_location_services')
1424+
self.command_executor._commands[Command.GET_LOCATION] = \
1425+
('GET', '/session/$sessionId/location')
1426+
self.command_executor._commands[Command.SET_LOCATION] = \
1427+
('POST', '/session/$sessionId/location')
1428+
14161429
self.command_executor._commands[Command.TOUCH_ACTION] = \
14171430
('POST', '/session/$sessionId/touch/perform')
14181431
self.command_executor._commands[Command.MULTI_ACTION] = \

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
'appium',
3838
'appium.common',
3939
'appium.webdriver',
40-
'appium.webdriver.common'
40+
'appium.webdriver.common',
41+
'appium.webdriver.extensions'
4142
],
4243
license='Apache 2.0',
4344
classifiers=[
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 appium_command, android_w3c_driver
16+
from appium.common.helper import appium_bytes
17+
18+
import httpretty
19+
20+
21+
class TestWebDriverDeviceContext(object):
22+
23+
@httpretty.activate
24+
def test_get_contexts(self):
25+
driver = android_w3c_driver()
26+
httpretty.register_uri(
27+
httpretty.GET,
28+
appium_command('/session/1234567890/context'),
29+
body='{"value": "NATIVE"}'
30+
)
31+
assert driver.current_context == 'NATIVE'

0 commit comments

Comments
 (0)