Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file.
Read `release_notes.md` for commit level details.

## [Unreleased]

This release has a breaking change about an implicit wait.
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.

### Enhancements
- Breaking changes
- Set implicit wait zero by default
- Can configure `wait: 20` as `appium_lib` capability to keep the behaviour
- [Experimental] Add `direct_connect` capability for the Ruby client in order to handle `directConnect` capability in a create session response by Appium server
- Update http client following `directConnectProtocol`, `directConnectHost`, `directConnectPort` and `directConnectPath`
if `direct_connect` capability for ruby_lib_core is `true`
Expand Down
7 changes: 4 additions & 3 deletions lib/appium_lib_core/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ class Driver
# @return [String] By default, session id is exported in '/tmp/appium_lib_session'
attr_reader :export_session_path

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

# Appium's server port. 4723 is by default.
# Provide Appium::Drive like { appium_lib: { port: 8080 } }
Expand Down Expand Up @@ -465,7 +466,7 @@ def set_app_path
# @private
def set_appium_lib_specific_values(appium_lib_opts)
@custom_url ||= appium_lib_opts.fetch :server_url, nil
@default_wait = appium_lib_opts.fetch :wait, 20
@default_wait = appium_lib_opts.fetch :wait, DEFAULT_IMPLICIT_WAIT

# bump current session id into a particular file
@export_session = appium_lib_opts.fetch :export_session, false
Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/android/mjpeg_server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setup
end

def teardown
save_reports(@@driver)
save_reports(@driver)
@@core.quit_driver
end

Expand Down
19 changes: 9 additions & 10 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def ios
},
appium_lib: {
export_session: true,
wait: 30,
wait_timeout: 20,
wait_interval: 1
}
Expand Down Expand Up @@ -125,11 +124,12 @@ def android(activity_name = nil)
# chromedriverExecutable: "#{Dir.pwd}/test/functional/app/chromedriver_2.34",
chromeOptions: {
args: ['--disable-popup-blocking']
}
},
uiautomator2ServerLaunchTimeout: 60_000 # ms
},
appium_lib: {
export_session: true,
wait: 30,
wait: 0,
wait_timeout: 20,
wait_interval: 1
}
Expand Down Expand Up @@ -175,7 +175,6 @@ def android_web
},
appium_lib: {
export_session: true,
wait: 30,
wait_timeout: 20,
wait_interval: 1
}
Expand Down Expand Up @@ -261,7 +260,7 @@ def android_mock_create_session
.to_return(headers: HEADER, status: 200, body: response)

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

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

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

driver = @core.start_driver

assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
driver
end

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

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

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

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

driver = @core.start_driver

assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 30_000 }.to_json, times: 1)
assert_requested(:post, "#{SESSION}/timeouts", body: { implicit: 0 }.to_json, times: 1)
driver
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/webdriver/w3c/timeouts_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_implicit_wait

@driver.manage.timeouts.implicit_wait = 30

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

def test_get_timeouts
Expand Down
20 changes: 10 additions & 10 deletions test/unit/common_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def test_create_session_force_mjsonwp
.to_return(headers: Mock::HEADER, status: 200, body: response)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

assert_equal 'http://example.com/test.apk.zip', core.caps[:app]
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_verify_appium_core_base_capabilities_create_capabilities
end

def test_default_wait
assert_equal 30, @core.default_wait
assert_equal 0, @core.default_wait
end

def test_default_timeout_for_http_client
Expand Down