Skip to content

Commit

Permalink
fix: keyword argument in Ruby 3
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Dec 26, 2020
1 parent 943e0da commit 6b2d7dd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Read `release_notes.md` for commit level details.
## [Unreleased]

### Enhancements
- Ruby 3.0 support

### Bug fixes
- Argument of `@driver.execute_cdp`
- It should be like `@driver.execute_cdp 'Page.captureScreenshot', quality: 50, format: 'jpeg'` as keyword arguments
instead of `@driver.execute_cdp 'Page.captureScreenshot', { quality: 50, format: 'jpeg' }` in Ruby 3

### Deprecations

Expand Down
8 changes: 4 additions & 4 deletions lib/appium_lib_core/android/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,16 @@ module Device
# @driver.finger_print 1
#

# @!method execute_cdp(cmd, params)
# @!method execute_cdp(cmd, **params)
# Execute Chrome Devtools protocol commands
# https://chromedevtools.github.io/devtools-protocol
#
# @param [String] cmd The name of command
# @param [Hash] params The parameter for the command as hash.
# @option params The parameter for the command as keyword options.
#
# @example
#
# @driver.execute_cdp 'Page.captureScreenshot', { quality: 50, format: 'jpeg' }
# @driver.execute_cdp 'Page.captureScreenshot', quality: 50, format: 'jpeg'
# @driver.execute_cdp 'Page.getResourceTree'
#

Expand Down Expand Up @@ -415,7 +415,7 @@ def end_coverage(path, intent)
# SeleniumWebdriver could already define this method
return if method_defined? :execute_cdp

def execute_cdp(cmd, params = {})
def execute_cdp(cmd, **params)
execute :chrome_send_command, {}, { cmd: cmd, params: params }
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/w3c/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def test_chromium_send_command
.with(body: { cmd: 'Page.captureScreenshot', params: { quality: 1, format: 'jpeg' } }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: { data: '/9j/4AAQSkZJRgABAQAAAQABAAD' } }.to_json)

r = @driver.execute_cdp 'Page.captureScreenshot', { quality: 1, format: 'jpeg' }
r = @driver.execute_cdp 'Page.captureScreenshot', quality: 1, format: 'jpeg'

assert_requested(:post, "#{SESSION}/goog/cdp/execute", times: 1)
assert_equal '/9j/4AAQSkZJRgABAQAAAQABAAD', r['data']
Expand Down

0 comments on commit 6b2d7dd

Please sign in to comment.