Skip to content

Commit 9cbad5c

Browse files
authored
add get timeouts for w3c (#46)
* add get timeouts for w3c * add testcode for timeouts * fix rubocop
1 parent dacdc36 commit 9cbad5c

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

lib/appium_lib_core/common/base/bridge/w3c.rb

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def action(async = false)
3434
end
3535
alias actions action
3636

37+
def get_timeouts
38+
execute :get_timeouts
39+
end
40+
3741
# For Appium
3842
# override
3943
def page_source

lib/appium_lib_core/common/base/driver.rb

+12
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ def back
6868
def logs
6969
@logs ||= Logs.new(@bridge)
7070
end
71+
72+
# For W3C.
73+
# Get the timeout related settings on the server side.
74+
#
75+
# @return [Hash]
76+
#
77+
# @example
78+
# @driver.get_timeouts
79+
#
80+
def get_timeouts
81+
@bridge.get_timeouts
82+
end
7183
end # class Driver
7284
end # class Base
7385
end # module Core

lib/appium_lib_core/common/command.rb

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ module Commands
8989
# The fix will be included in selenium-3.8.2
9090
get_page_source: [:get, 'session/:session_id/source'.freeze],
9191

92+
get_timeouts: [:get, 'session/:session_id/timeouts'.freeze],
93+
9294
## Add OSS commands to W3C commands
9395
### rotatable
9496
get_screen_orientation: [:get, 'session/:session_id/orientation'.freeze],

lib/appium_lib_core/common/device.rb

-5
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,6 @@ def extended(_mod)
403403
add_endpoint_method method
404404
end
405405

406-
# Don't define selenium-side methods. We pick up from them.
407-
# ::Appium::Core::Base::Commands::MJSONWP.each_key do |method|
408-
# add_endpoint_method method
409-
# end
410-
411406
add_endpoint_method(:available_contexts) do
412407
def available_contexts
413408
# return empty array instead of nil on failure

test/unit/android/webdriver_w3c_test.rb

+9
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ def test_active_element
9090

9191
assert_requested(:get, "#{SESSION}/element/active", times: 1)
9292
end
93+
94+
def test_get_timeouts
95+
stub_request(:get, "#{SESSION}/timeouts")
96+
.to_return(headers: HEADER, status: 200, body: { value: 'xxxx' }.to_json)
97+
98+
@driver.get_timeouts
99+
100+
assert_requested(:get, "#{SESSION}/timeouts", times: 1)
101+
end
93102
end
94103
end
95104
end

0 commit comments

Comments
 (0)