Skip to content

Commit 1315dae

Browse files
authored
set default zero implicit wait (#186)
* set default zero implicit wait * tweak tests
1 parent 61a927f commit 1315dae

File tree

7 files changed

+33
-26
lines changed

7 files changed

+33
-26
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file.
33
Read `release_notes.md` for commit level details.
44

55
## [Unreleased]
6+
7+
This release has a breaking change about an implicit wait.
8+
Ruby client sets `0` seconds as implicit wait by default from this release since it is the default spec behaviour in WebDriver while Ruby client had set `20` seconds for it.
9+
610
### Enhancements
11+
- Breaking changes
12+
- Set implicit wait zero by default
13+
- Can configure `wait: 20` as `appium_lib` capability to keep the behaviour
714
- [Experimental] Add `direct_connect` capability for the Ruby client in order to handle `directConnect` capability in a create session response by Appium server
815
- Update http client following `directConnectProtocol`, `directConnectHost`, `directConnectPort` and `directConnectPath`
916
if `direct_connect` capability for ruby_lib_core is `true`

lib/appium_lib_core/driver.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ class Driver
4343
# @return [String] By default, session id is exported in '/tmp/appium_lib_session'
4444
attr_reader :export_session_path
4545

46-
# Default wait time for elements to appear
47-
# Returns the default client side wait. 20 seconds is by default.
46+
# Default wait time for elements to appear in Appium server side.
47+
# Returns the default client side wait. 0 seconds is by default. Users should handle the timeout stuff in user-side.
4848
# Provide Appium::Drive like { appium_lib: { wait: 30 } }
4949
# @return [Integer]
5050
attr_reader :default_wait
51+
DEFAULT_IMPLICIT_WAIT = 0
5152

5253
# Appium's server port. 4723 is by default.
5354
# Provide Appium::Drive like { appium_lib: { port: 8080 } }
@@ -465,7 +466,7 @@ def set_app_path
465466
# @private
466467
def set_appium_lib_specific_values(appium_lib_opts)
467468
@custom_url ||= appium_lib_opts.fetch :server_url, nil
468-
@default_wait = appium_lib_opts.fetch :wait, 20
469+
@default_wait = appium_lib_opts.fetch :wait, DEFAULT_IMPLICIT_WAIT
469470

470471
# bump current session id into a particular file
471472
@export_session = appium_lib_opts.fetch :export_session, false

test/functional/android/android/mjpeg_server_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup
1111
end
1212

1313
def teardown
14-
save_reports(@@driver)
14+
save_reports(@driver)
1515
@@core.quit_driver
1616
end
1717

test/test_helper.rb

+9-10
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def ios
9292
},
9393
appium_lib: {
9494
export_session: true,
95-
wait: 30,
9695
wait_timeout: 20,
9796
wait_interval: 1
9897
}
@@ -125,11 +124,12 @@ def android(activity_name = nil)
125124
# chromedriverExecutable: "#{Dir.pwd}/test/functional/app/chromedriver_2.34",
126125
chromeOptions: {
127126
args: ['--disable-popup-blocking']
128-
}
127+
},
128+
uiautomator2ServerLaunchTimeout: 60_000 # ms
129129
},
130130
appium_lib: {
131131
export_session: true,
132-
wait: 30,
132+
wait: 0,
133133
wait_timeout: 20,
134134
wait_interval: 1
135135
}
@@ -175,7 +175,6 @@ def android_web
175175
},
176176
appium_lib: {
177177
export_session: true,
178-
wait: 30,
179178
wait_timeout: 20,
180179
wait_interval: 1
181180
}
@@ -261,7 +260,7 @@ def android_mock_create_session
261260
.to_return(headers: HEADER, status: 200, body: response)
262261

263262
stub_request(:post, "#{SESSION}/timeouts/implicit_wait")
264-
.with(body: { ms: 30_000 }.to_json)
263+
.with(body: { ms: 0 }.to_json)
265264
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
266265

267266
driver = @core.start_driver
@@ -294,13 +293,13 @@ def android_mock_create_session_w3c
294293
.to_return(headers: HEADER, status: 200, body: response)
295294

296295
stub_request(:post, "#{SESSION}/timeouts")
297-
.with(body: { implicit: 30_000 }.to_json)
296+
.with(body: { implicit: 0 }.to_json)
298297
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
299298

300299
driver = @core.start_driver
301300

302301
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
303-
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
302+
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
304303
driver
305304
end
306305

@@ -360,7 +359,7 @@ def ios_mock_create_session
360359
.to_return(headers: HEADER, status: 200, body: response)
361360

362361
stub_request(:post, "#{SESSION}/timeouts/implicit_wait")
363-
.with(body: { ms: 30_000 }.to_json)
362+
.with(body: { ms: 0 }.to_json)
364363
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
365364

366365
driver = @core.start_driver
@@ -387,13 +386,13 @@ def ios_mock_create_session_w3c
387386
.to_return(headers: HEADER, status: 200, body: response)
388387

389388
stub_request(:post, "#{SESSION}/timeouts")
390-
.with(body: { implicit: 30_000 }.to_json)
389+
.with(body: { implicit: 0 }.to_json)
391390
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
392391

393392
driver = @core.start_driver
394393

395394
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
396-
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
395+
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
397396
driver
398397
end
399398
end

test/unit/android/webdriver/w3c/timeouts_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_implicit_wait
2121

2222
@driver.manage.timeouts.implicit_wait = 30
2323

24-
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 2)
24+
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
2525
end
2626

2727
def test_get_timeouts

test/unit/common_test.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ def test_create_session_force_mjsonwp
5252
.to_return(headers: Mock::HEADER, status: 200, body: response)
5353

5454
stub_request(:post, "#{Mock::SESSION}/timeouts/implicit_wait")
55-
.with(body: { ms: 20_000 }.to_json)
55+
.with(body: { ms: 0 }.to_json)
5656
.to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json)
5757

5858
driver = ::Appium::Core.for({ caps: CAPS.merge({ forceMjsonwp: true }), appium_lib: {} }).start_driver
5959

6060
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
61-
assert_requested(:post, "#{Mock::SESSION}/timeouts/implicit_wait", body: { ms: 20_000 }.to_json, times: 1)
61+
assert_requested(:post, "#{Mock::SESSION}/timeouts/implicit_wait", body: { ms: 0 }.to_json, times: 1)
6262
driver
6363
end
6464

@@ -71,13 +71,13 @@ def test_create_session_force_mjsonwp_false
7171
.to_return(headers: Mock::HEADER, status: 200, body: response)
7272

7373
stub_request(:post, "#{Mock::SESSION}/timeouts")
74-
.with(body: { implicit: 20_000 }.to_json)
74+
.with(body: { implicit: 0 }.to_json)
7575
.to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json)
7676

7777
driver = ::Appium::Core.for({ caps: CAPS.merge({ forceMjsonwp: false }), appium_lib: {} }).start_driver
7878

7979
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
80-
assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 20_000 }.to_json, times: 1)
80+
assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
8181
driver
8282
end
8383

@@ -110,14 +110,14 @@ def test_create_session_force_mjsonwp_with_source_package
110110
.to_return(headers: Mock::HEADER, status: 200, body: response)
111111

112112
stub_request(:post, "#{Mock::SESSION}/timeouts/implicit_wait")
113-
.with(body: { ms: 20_000 }.to_json)
113+
.with(body: { ms: 0 }.to_json)
114114
.to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json)
115115

116116
core = ::Appium::Core.for({ caps: http_caps.merge({ forceMjsonwp: true }), appium_lib: {} })
117117
core.start_driver
118118

119119
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
120-
assert_requested(:post, "#{Mock::SESSION}/timeouts/implicit_wait", body: { ms: 20_000 }.to_json, times: 1)
120+
assert_requested(:post, "#{Mock::SESSION}/timeouts/implicit_wait", body: { ms: 0 }.to_json, times: 1)
121121

122122
assert_equal 'sauce-storage:test/functional/app/api.apk.zip', core.caps[:app]
123123
end
@@ -131,13 +131,13 @@ def test_create_session_w3c
131131
.to_return(headers: Mock::HEADER, status: 200, body: response)
132132

133133
stub_request(:post, "#{Mock::SESSION}/timeouts")
134-
.with(body: { implicit: 20_000 }.to_json)
134+
.with(body: { implicit: 0 }.to_json)
135135
.to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json)
136136

137137
driver = ::Appium::Core.for({ caps: CAPS, appium_lib: {} }).start_driver
138138

139139
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
140-
assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 20_000 }.to_json, times: 1)
140+
assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
141141
driver
142142
end
143143

@@ -179,14 +179,14 @@ def test_create_session_w3c_with_http_package
179179
.to_return(headers: Mock::HEADER, status: 200, body: response)
180180

181181
stub_request(:post, "#{Mock::SESSION}/timeouts")
182-
.with(body: { implicit: 20_000 }.to_json)
182+
.with(body: { implicit: 0 }.to_json)
183183
.to_return(headers: Mock::HEADER, status: 200, body: { value: nil }.to_json)
184184

185185
core = ::Appium::Core.for({ caps: http_caps, appium_lib: {} })
186186
core.start_driver
187187

188188
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
189-
assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 20_000 }.to_json, times: 1)
189+
assert_requested(:post, "#{Mock::SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
190190

191191
assert_equal 'http://example.com/test.apk.zip', core.caps[:app]
192192
end

test/unit/driver_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_verify_appium_core_base_capabilities_create_capabilities
7171
end
7272

7373
def test_default_wait
74-
assert_equal 30, @core.default_wait
74+
assert_equal 0, @core.default_wait
7575
end
7676

7777
def test_default_timeout_for_http_client

0 commit comments

Comments
 (0)