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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
### Bug fixes

### Deprecations
- `@core = Appium::Core.for(self, opts)` is deprecated in favor of `@core = Appium::Core.for(opts)`
- Call `extend Appium::Core::Device` if you'd like to extend methods defined in `Appium::Core`
- Read [#816](https://github.com/appium/ruby_lib/pull/816) as an example

## [1.9.2] - 2018-08-23
### Enhancements
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Run functional tests which require the Appium server and real device, Simulator/

- Start Appium server
```bash
$ npm install -g appium
$ appium
$ npm install -g appium opencv4nodejs
$ appium --relaxed-security # To run all tests in rocal
```

- Conduct tests
Expand Down Expand Up @@ -68,7 +68,7 @@ opts = {
wait: 30
}
}
@core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self`
@core = Appium::Core.for(opts) # create a core driver with `opts`
@driver = @core.start_driver

# Launch iPhone Simulator and `MyiOS.app`
Expand Down
4 changes: 2 additions & 2 deletions lib/appium_lib_core/common/base/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.handshake(**opts)
# wait: 30
# }
# }
# core = ::Appium::Core.for(self, caps)
# core = ::Appium::Core.for(caps)
# driver = core.start_driver #=> driver.dialect == :oss
#
# @example
Expand All @@ -85,7 +85,7 @@ def self.handshake(**opts)
# wait: 30
# }
# }
# core = ::Appium::Core.for(self, caps)
# core = ::Appium::Core.for(caps)
# driver = core.start_driver #=> driver.dialect == :w3c if the Appium server support W3C.
#
def create_session(desired_capabilities)
Expand Down
2 changes: 1 addition & 1 deletion lib/appium_lib_core/common/touch_action/multi_touch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Core
#
# @example
#
# @driver = Appium::Core.for(self, opts).start_driver
# @driver = Appium::Core.for(opts).start_driver
# action_1 = TouchAction.new(@driver).press(x: 45, y: 100).wait(5).release
# action_2 = TouchAction.new(@driver).tap(element: el, x: 50, y:5, count: 3)
#
Expand Down
2 changes: 1 addition & 1 deletion lib/appium_lib_core/common/touch_action/touch_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Core
#
# @example
#
# @driver = Appium::Core.for(self, opts).start_driver
# @driver = Appium::Core.for(opts).start_driver
# action = TouchAction.new(@driver).press(x: 45, y: 100).wait(5).release
# action.perform
# action = TouchAction.new(@driver).swipe(....)
Expand Down
2 changes: 1 addition & 1 deletion lib/appium_lib_core/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class << self
def extended(_mod)
extend_webdriver_with_forwardable

# Compatibility for appium_lib
# Compatibility for appium_lib. Below command are extended by `extend Appium::Core::Deivce`in appium_lib.
# TODO: Will remove
[
:take_element_screenshot, :save_viewport_screenshot,
Expand Down
26 changes: 13 additions & 13 deletions lib/appium_lib_core/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Driver
# listener: nil,
# }
# }
# @core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self`
# @core = Appium::Core.for(opts) # create a core driver with `opts` and extend methods into `self`
# @core.start_driver(server_url: server_url) # start driver
#
# # Start iOS driver with .zip file over HTTP
Expand All @@ -125,11 +125,11 @@ class Driver
# listener: nil,
# }
# }
# @core = Appium::Core.for(self, opts)
# @core = Appium::Core.for(opts)
# @core.start_driver(server_url: server_url)
#
def self.for(target, opts = {})
new(target, opts)
def self.for(opts = {})
new(opts)
end

# @private
Expand All @@ -139,8 +139,8 @@ def self.for(target, opts = {})
end

# @private
def initialize(target, opts = {})
@delegate_target = target # for testing purpose
def initialize(opts = {})
@delegate_target = self # for testing purpose

opts = Appium.symbolize_keys opts
validate_keys(opts)
Expand All @@ -152,7 +152,7 @@ def initialize(target, opts = {})
set_appium_device
set_automation_name

extend_for(device: @device, automation_name: @automation_name, target: target)
extend_for(device: @device, automation_name: @automation_name)

self # rubocop:disable Lint/Void
end
Expand Down Expand Up @@ -190,8 +190,8 @@ def initialize(target, opts = {})
# }
# }
#
# @core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self`
# @driver = @core.start_driver
# @core = Appium::Core.for(opts) # create a core driver with `opts` and extend methods into `self`
# @driver = @core.start_driver server_url: "http://127.0.0.1:8000/wd/hub"
#

def start_driver(server_url: nil,
Expand Down Expand Up @@ -318,9 +318,9 @@ def screenshot(png_save_path)
private

# @private
def extend_for(device:, automation_name:, target:)
target.extend Appium::Core
target.extend Appium::Core::Device
def extend_for(device:, automation_name:)
extend Appium::Core
extend Appium::Core::Device

case device
when :android
Expand Down Expand Up @@ -352,7 +352,7 @@ def extend_for(device:, automation_name:, target:)
Appium::Logger.warn('no device matched')
end

target
self
end

# @private
Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/android/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module Android
class DeviceTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.android)
@@core ||= ::Appium::Core.for(Caps.android)
@driver = @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/android/search_context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module Android
class SearchContextTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.android)
@@core ||= ::Appium::Core.for(Caps.android)
@driver = @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class AppiumLibCoreTest
class DriverTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.android)
@@core ||= ::Appium::Core.for(Caps.android)
@driver = @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class AppiumLibCoreTest
class PathTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.android)
@@core ||= ::Appium::Core.for(Caps.android)
@driver = @@core.start_driver
end

Expand Down
6 changes: 3 additions & 3 deletions test/functional/android/webdriver/create_session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateSessionTestTest < AppiumLibCoreTest::Function::TestCase
def test_mjsonwp
caps = Caps.android[:caps].merge({ forceMjsonwp: true })
new_caps = Caps.android.merge({ caps: caps })
core = ::Appium::Core.for(self, new_caps)
core = ::Appium::Core.for(new_caps)

driver = core.start_driver

Expand All @@ -20,7 +20,7 @@ def test_mjsonwp
def test_w3c
caps = Caps.android[:caps].merge({ forceMjsonwp: false })
new_caps = Caps.android.merge({ caps: caps })
core = ::Appium::Core.for(self, new_caps)
core = ::Appium::Core.for(new_caps)

driver = core.start_driver

Expand All @@ -32,7 +32,7 @@ def test_w3c
# Require Appium 1.7.2+
def test_w3c_default
caps = Caps.android
core = ::Appium::Core.for(self, caps)
core = ::Appium::Core.for(caps)

driver = core.start_driver

Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module WebDriver
class DeviceTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.android)
@@core ||= ::Appium::Core.for(Caps.android)
@driver = @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/android/webdriver/w3c_actions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module WebDriver
class W3CActionsTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.android)
@@core ||= ::Appium::Core.for(Caps.android)
@driver = @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class AppiumLibCoreTest
class DriverTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.ios)
@@core ||= ::Appium::Core.for(Caps.ios)
@@driver ||= @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/ios/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AppiumLibCoreTest
module Ios
class DeviceTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.ios)
@@core ||= ::Appium::Core.for(Caps.ios)
@@driver ||= @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/ios/search_context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module Ios
class SearchContextTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.ios)
@@core ||= ::Appium::Core.for(Caps.ios)
@@driver ||= @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class AppiumLibCoreTest
class PathTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.ios)
@@core ||= ::Appium::Core.for(Caps.ios)
@@driver ||= @@core.start_driver
end

Expand Down
6 changes: 3 additions & 3 deletions test/functional/ios/webdriver/create_session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CreateSessionTestTest < AppiumLibCoreTest::Function::TestCase
def test_mjsonwp
caps = Caps.ios[:caps].merge({ forceMjsonwp: true })
new_caps = Caps.ios.merge({ caps: caps })
core = ::Appium::Core.for(self, new_caps)
core = ::Appium::Core.for(new_caps)

driver = core.start_driver

Expand All @@ -20,7 +20,7 @@ def test_mjsonwp
def test_w3c
caps = Caps.ios[:caps].merge({ forceMjsonwp: false })
new_caps = Caps.ios.merge({ caps: caps })
core = ::Appium::Core.for(self, new_caps)
core = ::Appium::Core.for(new_caps)

driver = core.start_driver

Expand All @@ -32,7 +32,7 @@ def test_w3c
# Require Appium 1.7.2+
def test_w3c_default
caps = Caps.ios
core = ::Appium::Core.for(self, caps)
core = ::Appium::Core.for(caps)

driver = core.start_driver

Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module WebDriver
class DeviceTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.ios)
@@core ||= ::Appium::Core.for(Caps.ios)
@@driver ||= @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/ios/webdriver/w3c_actions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppiumLibCoreTest
module WebDriver
class W3CActionsTest < AppiumLibCoreTest::Function::TestCase
def setup
@@core ||= ::Appium::Core.for(self, Caps.ios)
@@core ||= ::Appium::Core.for(Caps.ios)
@@driver ||= @@core.start_driver
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/app_management_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppManagementTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CommandsTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/contexts_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ContextsTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/definition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DefinitionTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/device_lock_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DeviceLockTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CommandsTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/ime_actions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ImeActionsTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/keyboard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class KeyboardTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/android/device/mjsonwp/screenshot_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ScreenshotTest < Minitest::Test
include AppiumLibCoreTest::Mock

def setup
@core ||= ::Appium::Core.for(self, Caps.android)
@core ||= ::Appium::Core.for(Caps.android)
@driver ||= android_mock_create_session
end

Expand Down
Loading