Skip to content

Commit b430234

Browse files
committed
[rb] move errors to driver extensions
1 parent 2b2c2ce commit b430234

File tree

4 files changed

+9
-118
lines changed

4 files changed

+9
-118
lines changed

rb/lib/selenium/webdriver/common/driver_extensions/has_location.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
# TODO: Deprecated; Delete after 4.0 release
2021
module Selenium
2122
module WebDriver
2223
module DriverExtensions
2324
module HasLocation
2425
def location
25-
@bridge.location
26+
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting location'
2627
end
2728

28-
def location=(loc)
29-
raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
30-
31-
@bridge.set_location loc.latitude, loc.longitude, loc.altitude
29+
def location=(*)
30+
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
3231
end
32+
alias_method :set_location, :location
3333

34-
def set_location(lat, lon, alt)
35-
self.location = Location.new(Float(lat), Float(lon), Float(alt))
36-
end
3734
end # HasLocation
3835
end # DriverExtensions
3936
end # WebDriver

rb/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,17 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20+
# TODO: Deprecated; Delete after 4.0 release
2021
module Selenium
2122
module WebDriver
2223
module DriverExtensions
2324
module HasNetworkConnection
2425
def network_connection_type
25-
connection_value = @bridge.network_connection
26-
27-
connection_type = values_to_type[connection_value]
28-
29-
# In case the connection type is not recognized return the
30-
# connection value.
31-
connection_type || connection_value
32-
end
33-
34-
def network_connection_type=(connection_type)
35-
raise ArgumentError, 'Invalid connection type' unless valid_type? connection_type
36-
37-
connection_value = type_to_values[connection_type]
38-
39-
@bridge.network_connection = connection_value
40-
end
41-
42-
private
43-
44-
def type_to_values
45-
{airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
46-
end
47-
48-
def values_to_type
49-
type_to_values.invert
26+
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting network connection'
5027
end
5128

52-
def valid_type?(type)
53-
type_to_values.key? type
29+
def network_connection_type=(*)
30+
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection'
5431
end
5532
end # HasNetworkConnection
5633
end # DriverExtensions

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,6 @@ def session_storage_size
307307
execute_script('return sessionStorage.length')
308308
end
309309

310-
def location
311-
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting location'
312-
end
313-
314-
def set_location(_lat, _lon, _alt)
315-
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
316-
end
317-
318-
def network_connection
319-
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting network connection'
320-
end
321-
322-
def network_connection=(_type)
323-
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection'
324-
end
325-
326310
#
327311
# javascript execution
328312
#

rb/spec/unit/selenium/webdriver/common/driver_extensions/has_network_connection_spec.rb

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)