Skip to content

Commit 51d902e

Browse files
authored
Merge branch 'appium:master' into refactor-remove-applications-fallbacks-1308480277413524913
2 parents f37be77 + 2a05afc commit 51d902e

5 files changed

Lines changed: 30 additions & 58 deletions

File tree

appium/webdriver/extensions/android/gsm.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from selenium.common.exceptions import UnknownMethodException
1615
from typing_extensions import Self
1716

1817
from appium.common.helper import extract_const_attributes
1918
from appium.common.logger import logger
2019
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
2120
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
22-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
23-
from appium.webdriver.mobilecommand import MobileCommand as Command
2421

2522

2623
class GsmCallActions:
@@ -48,7 +45,7 @@ class GsmVoiceState:
4845
ON = 'on'
4946

5047

51-
class Gsm(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
48+
class Gsm(CanExecuteCommands, CanExecuteScripts):
5249
def make_gsm_call(self, phone_number: str, action: str) -> Self:
5350
"""Make GSM call (Emulator only)
5451
@@ -73,11 +70,7 @@ def make_gsm_call(self, phone_number: str, action: str) -> Self:
7370
f'(e.g. {GsmCallActions.__name__}.CALL)'
7471
)
7572
args = {'phoneNumber': phone_number, 'action': action}
76-
try:
77-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
78-
except UnknownMethodException:
79-
# TODO: Remove the fallback
80-
self.mark_extension_absence(ext_name).execute(Command.MAKE_GSM_CALL, args)
73+
self.execute_script(ext_name, args)
8174
return self
8275

8376
def set_gsm_signal(self, strength: int) -> Self:
@@ -102,13 +95,7 @@ def set_gsm_signal(self, strength: int) -> Self:
10295
f'{strength} is out of range. Consider using one of {list(constants.keys())} constants. '
10396
f'(e.g. {GsmSignalStrength.__name__}.GOOD)'
10497
)
105-
try:
106-
self.assert_extension_exists(ext_name).execute_script(ext_name, {'strength': strength})
107-
except UnknownMethodException:
108-
# TODO: Remove the fallback
109-
self.mark_extension_absence(ext_name).execute(
110-
Command.SET_GSM_SIGNAL, {'signalStrength': strength, 'signalStrengh': strength}
111-
)
98+
self.execute_script(ext_name, {'strength': strength})
11299
return self
113100

114101
def set_gsm_voice(self, state: str) -> Self:
@@ -134,14 +121,8 @@ def set_gsm_voice(self, state: str) -> Self:
134121
f'(e.g. {GsmVoiceState.__name__}.HOME)'
135122
)
136123
args = {'state': state}
137-
try:
138-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
139-
except UnknownMethodException:
140-
# TODO: Remove the fallback
141-
self.mark_extension_absence(ext_name).execute(Command.SET_GSM_VOICE, args)
124+
self.execute_script(ext_name, args)
142125
return self
143126

144127
def _add_commands(self) -> None:
145-
self.command_executor.add_command(Command.MAKE_GSM_CALL, 'POST', '/session/$sessionId/appium/device/gsm_call')
146-
self.command_executor.add_command(Command.SET_GSM_SIGNAL, 'POST', '/session/$sessionId/appium/device/gsm_signal')
147-
self.command_executor.add_command(Command.SET_GSM_VOICE, 'POST', '/session/$sessionId/appium/device/gsm_voice')
128+
pass

appium/webdriver/extensions/location.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from typing import Dict, Union
1616

17-
from selenium.common.exceptions import UnknownMethodException
1817
from typing_extensions import Self
1918

2019
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
@@ -33,11 +32,7 @@ def toggle_location_services(self) -> Self:
3332
Returns:
3433
Union['WebDriver', 'Location']: Self instance
3534
"""
36-
try:
37-
self.execute_script('mobile: toggleGps')
38-
except UnknownMethodException:
39-
# TODO: Remove the fallback
40-
self.execute(Command.TOGGLE_LOCATION_SERVICES)
35+
self.execute_script('mobile: toggleGps')
4136
return self
4237

4338
def set_location(
@@ -89,10 +84,5 @@ def location(self) -> Dict[str, float]:
8984

9085
def _add_commands(self) -> None:
9186
"""Add location endpoints. They are not int w3c spec."""
92-
self.command_executor.add_command(
93-
Command.TOGGLE_LOCATION_SERVICES,
94-
'POST',
95-
'/session/$sessionId/appium/device/toggle_location_services',
96-
)
9787
self.command_executor.add_command(Command.GET_LOCATION, 'GET', '/session/$sessionId/location')
9888
self.command_executor.add_command(Command.SET_LOCATION, 'POST', '/session/$sessionId/location')

appium/webdriver/mobilecommand.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class MobileCommand:
8181
GET_SYSTEM_BARS = 'getSystemBars'
8282
GET_DISPLAY_DENSITY = 'getDisplayDensity'
8383
TOGGLE_WIFI = 'toggleWiFi'
84-
TOGGLE_LOCATION_SERVICES = 'toggleLocationServices'
8584
GET_PERFORMANCE_DATA_TYPES = 'getPerformanceDataTypes'
8685
GET_PERFORMANCE_DATA = 'getPerformanceData'
8786
GET_NETWORK_CONNECTION = 'getNetworkConnection'

test/unit/webdriver/device/location_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ class TestWebDriverLocation(object):
2424
@httpretty.activate
2525
def test_toggle_location_services(self):
2626
driver = android_w3c_driver()
27-
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/appium/device/toggle_location_services'))
2827
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
2928
assert isinstance(driver.toggle_location_services(), WebDriver)
3029

30+
d = get_httpretty_request_body(httpretty.last_request())
31+
assert d['script'] == 'mobile: toggleGps'
32+
3133
@httpretty.activate
3234
def test_set_location_float(self):
3335
driver = android_w3c_driver()

uv.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)