appium_console 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/appium_console.gemspec +1 -1
- data/lib/appium_console/version.rb +2 -2
- data/lib/appium_console.rb +10 -11
- data/lib/cli.rb +6 -0
- data/lib/start.rb +2 -0
- data/readme.md +26 -0
- data/test/cli_test.rb +38 -2
- data/test/console_test.rb +6 -12
- data/test/simple.rb +9 -8
- data/test/support/offline_session.rb +22 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33c7927fb9cb8e529632cfb4f019751838a24de1ececea900b8deba363a9f62b
|
|
4
|
+
data.tar.gz: b30cbe1f9a635cddfa017e3e23a811ad696e11db4106a30f04d284606c2547a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90dc13be5c5085320ce09bcb0f9c0b67c26c671524c5d9e50678c27c46048ca385a400ff88dc837095c46f3e38f5492fc302e032335fe79ffe6c13508aaec07f
|
|
7
|
+
data.tar.gz: 5fdfb600da8a5173cb8410a37491130780750df55f205e5e93be23c09e3d8d1c6d7715ded63369ec66bbc9261a439a6970e95a1be41c6f756fa5afa7bd4e7969
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
Historical commit-level notes through 4.2.0 are in [release_notes.md](release_notes.md).
|
|
4
4
|
New entries are maintained by Release Please.
|
|
5
5
|
|
|
6
|
+
## [4.4.0](https://github.com/appium/ruby_console/compare/v4.3.1...v4.4.0) (2026-11-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* support multiple sessions while preserving console shortcuts ([#275](https://github.com/appium/ruby_console/issues/275)) ([f0e9be6](https://github.com/appium/ruby_console/commit/f0e9be65d498d5e0bdfeeb00ee8ef1c81ea4ad40))
|
|
12
|
+
|
|
6
13
|
## [4.3.1](https://github.com/appium/ruby_console/compare/v4.3.0...v4.3.1) (2026-10-28)
|
|
7
14
|
|
|
8
15
|
|
data/Gemfile
CHANGED
data/appium_console.gemspec
CHANGED
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
|
22
22
|
s.require_paths = ['lib']
|
|
23
23
|
|
|
24
24
|
# appium_lib version must match ruby console version.
|
|
25
|
-
s.add_dependency 'appium_lib', '>=
|
|
25
|
+
s.add_dependency 'appium_lib', '>= 17.0.0'
|
|
26
26
|
s.add_dependency 'pry', '>= 0.14', '< 0.17'
|
|
27
27
|
s.add_dependency 'thor', '>= 0.19', '< 2.0'
|
|
28
28
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
module Appium; end unless defined? Appium
|
|
5
5
|
module Appium
|
|
6
6
|
module Console
|
|
7
|
-
VERSION = '4.
|
|
8
|
-
DATE = '2026-
|
|
7
|
+
VERSION = '4.4.0' unless defined? ::Appium::Console::VERSION
|
|
8
|
+
DATE = '2026-11-22' unless defined? ::Appium::Console::DATE # x-release-please-date
|
|
9
9
|
end
|
|
10
10
|
end
|
data/lib/appium_console.rb
CHANGED
|
@@ -48,28 +48,27 @@ module Appium
|
|
|
48
48
|
$stdout.puts "pry #{cmd.join(' ')}"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
register_release_session_hook
|
|
52
|
-
|
|
53
51
|
opts = Pry::CLI.parse_options cmd
|
|
54
52
|
Pry::CLI.start(opts)
|
|
55
53
|
end
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def define_pry_method(name, &)
|
|
60
|
-
Pry.singleton_class.send(:remove_method, name) if Pry.respond_to?(name)
|
|
61
|
-
Pry.send(:define_singleton_method, name, &)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def register_release_session_hook
|
|
55
|
+
def register_release_session_hook(driver)
|
|
65
56
|
if Pry.hooks.hook_exists?(:after_session, 'Release session hook')
|
|
66
57
|
Pry.hooks.delete_hook(:after_session, 'Release session hook')
|
|
67
58
|
end
|
|
68
59
|
Pry.hooks.add_hook(:after_session, 'Release session hook') do |output, _binding, _pry|
|
|
69
60
|
output.puts 'Closing appium session...'
|
|
70
|
-
|
|
61
|
+
driver.driver_quit
|
|
62
|
+
$driver = nil if $driver.equal?(driver)
|
|
71
63
|
end
|
|
72
64
|
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def define_pry_method(name, &)
|
|
69
|
+
Pry.singleton_class.send(:remove_method, name) if Pry.respond_to?(name)
|
|
70
|
+
Pry.send(:define_singleton_method, name, &)
|
|
71
|
+
end
|
|
73
72
|
end
|
|
74
73
|
end
|
|
75
74
|
end
|
data/lib/cli.rb
CHANGED
|
@@ -97,6 +97,12 @@ appium_console: v#{::Appium::Console::VERSION}
|
|
|
97
97
|
end
|
|
98
98
|
default_command :init
|
|
99
99
|
|
|
100
|
+
desc 'multi', 'Starts a console for managing independent Appium sessions'
|
|
101
|
+
def multi
|
|
102
|
+
Pry.config.command_prefix = '%'
|
|
103
|
+
Pry::CLI.start(Pry::CLI.parse_options([]))
|
|
104
|
+
end
|
|
105
|
+
|
|
100
106
|
desc 'setup', 'Generates toml file'
|
|
101
107
|
subcommand 'setup', Setup
|
|
102
108
|
end
|
data/lib/start.rb
CHANGED
|
@@ -17,7 +17,9 @@ new_command_timeout = { caps: (has_command_timeout ? {} : { newCommandTimeout: 9
|
|
|
17
17
|
opts = opts.merge(new_command_timeout)
|
|
18
18
|
core = Appium::Driver.new opts, false
|
|
19
19
|
core.start_driver
|
|
20
|
+
$driver = core
|
|
20
21
|
Appium.promote_appium_methods Object, core
|
|
22
|
+
Appium::Console.register_release_session_hook(core)
|
|
21
23
|
|
|
22
24
|
# Load minitest
|
|
23
25
|
begin
|
data/readme.md
CHANGED
|
@@ -21,6 +21,32 @@
|
|
|
21
21
|
- `arc setup ios` creates `appium.txt` for ios in the current working dir.
|
|
22
22
|
- Setup preserves an existing `appium.txt`. Add `--force` to overwrite it.
|
|
23
23
|
- `arc toml FILE` starts arc with toml FILE path
|
|
24
|
+
- `arc multi` opens a console where you start and stop each session yourself.
|
|
25
|
+
|
|
26
|
+
### Using the configured session
|
|
27
|
+
|
|
28
|
+
`arc`, `arc init`, and `arc toml FILE` start the configured session.
|
|
29
|
+
The console exposes that session as `$driver` and makes commands such as
|
|
30
|
+
`get_source` available at the prompt and in page objects. Exit the console
|
|
31
|
+
to close the session.
|
|
32
|
+
|
|
33
|
+
### Managing multiple sessions
|
|
34
|
+
|
|
35
|
+
Run `arc multi` and load a configuration for each device. Keep each driver
|
|
36
|
+
in its own variable and call commands on the driver you want to use.
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
ios = Appium::Driver.new(Appium.load_appium_txt(file: 'ios.txt'), false)
|
|
40
|
+
android = Appium::Driver.new(Appium.load_appium_txt(file: 'android.txt'), false)
|
|
41
|
+
ios.start_driver
|
|
42
|
+
android.start_driver
|
|
43
|
+
|
|
44
|
+
ios.get_source
|
|
45
|
+
android.get_source
|
|
46
|
+
|
|
47
|
+
ios.driver_quit
|
|
48
|
+
android.driver_quit
|
|
49
|
+
```
|
|
24
50
|
|
|
25
51
|
## Documentation
|
|
26
52
|
|
data/test/cli_test.rb
CHANGED
|
@@ -8,8 +8,44 @@ require 'tomlrb'
|
|
|
8
8
|
class CliTest < Minitest::Test
|
|
9
9
|
ROOT = File.expand_path('..', __dir__)
|
|
10
10
|
|
|
11
|
-
def run_arc(*args)
|
|
12
|
-
|
|
11
|
+
def run_arc(*args, offline: false, **options)
|
|
12
|
+
preload = offline ? ['-r', File.join(__dir__, 'support/offline_session')] : []
|
|
13
|
+
Open3.capture3(Gem.ruby, *preload, '-I', File.join(ROOT, 'lib'), File.join(ROOT, 'bin/arc'), *args, **options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_configured_console_exposes_global_and_bare_methods
|
|
17
|
+
Dir.mktmpdir do |dir|
|
|
18
|
+
File.write(File.join(dir, 'appium.txt'), <<~TOML)
|
|
19
|
+
[caps]
|
|
20
|
+
platformName = "iOS"
|
|
21
|
+
automationName = "XCUITest"
|
|
22
|
+
TOML
|
|
23
|
+
input = 'puts [get_source, $driver.get_source, Object.new.get_source].join("/")'
|
|
24
|
+
stdout, stderr, status = run_arc(stdin_data: input, chdir: dir, offline: true)
|
|
25
|
+
assert status.success?, stderr
|
|
26
|
+
assert_includes stdout, "ios/ios/ios\n"
|
|
27
|
+
assert_includes stdout, "closed ios\n"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_multi_sessions_can_be_used_and_closed_independently
|
|
32
|
+
Dir.mktmpdir do |dir|
|
|
33
|
+
input = <<~RUBY
|
|
34
|
+
ios = Appium::Driver.new({ caps: { platformName: 'iOS', automationName: 'XCUITest' } }, false)
|
|
35
|
+
android = Appium::Driver.new({ caps: { platformName: 'Android', automationName: 'UiAutomator2' } }, false)
|
|
36
|
+
ios.start_driver
|
|
37
|
+
android.start_driver
|
|
38
|
+
puts [ios.get_source, android.get_source, $driver.nil?, respond_to?(:get_source, true)].join("/")
|
|
39
|
+
ios.driver_quit
|
|
40
|
+
puts "remaining " + android.get_source
|
|
41
|
+
android.driver_quit
|
|
42
|
+
RUBY
|
|
43
|
+
stdout, stderr, status = run_arc('multi', stdin_data: input, chdir: dir, offline: true)
|
|
44
|
+
assert status.success?, stderr
|
|
45
|
+
assert_includes stdout, "ios/android/true/false\n"
|
|
46
|
+
assert_includes stdout, "remaining android\n"
|
|
47
|
+
assert_includes stdout, "closed android\n"
|
|
48
|
+
end
|
|
13
49
|
end
|
|
14
50
|
|
|
15
51
|
def test_setup_generates_driver_and_server_settings
|
data/test/console_test.rb
CHANGED
|
@@ -44,20 +44,14 @@ class ConsoleTest < Minitest::Test
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Appium::Console.start
|
|
53
|
-
Appium::Console.start
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
47
|
+
def test_after_session_hook_releases_only_the_registered_driver
|
|
48
|
+
driver = Minitest::Mock.new
|
|
49
|
+
driver.expect(:driver_quit, nil)
|
|
50
|
+
Appium::Console.register_release_session_hook(Object.new)
|
|
51
|
+
Appium::Console.register_release_session_hook(driver)
|
|
57
52
|
output = StringIO.new
|
|
58
|
-
Pry.hooks.errors.clear
|
|
59
53
|
Pry.hooks.get_hook(:after_session, 'Release session hook').call(output, binding, Pry.new)
|
|
60
|
-
|
|
54
|
+
driver.verify
|
|
61
55
|
assert_includes output.string, 'Closing appium session...'
|
|
62
56
|
ensure
|
|
63
57
|
Pry.hooks.delete_hook(:after_session, 'Release session hook')
|
data/test/simple.rb
CHANGED
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
require 'rubygems'
|
|
9
9
|
require 'appium_lib'
|
|
10
10
|
|
|
11
|
-
def sign_in
|
|
12
|
-
button('Sign In').click
|
|
11
|
+
def sign_in(driver)
|
|
12
|
+
driver.button('Sign In').click
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
driver = Appium::Driver.new(Appium.load_appium_txt(file: 'appium.txt'), false)
|
|
16
|
+
begin
|
|
17
|
+
driver.start_driver
|
|
18
|
+
sign_in(driver)
|
|
19
|
+
ensure
|
|
20
|
+
driver.driver_quit
|
|
21
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'appium_lib'
|
|
4
|
+
|
|
5
|
+
# Exercise the real appium_lib wrappers and console startup without a server.
|
|
6
|
+
module OfflineSession
|
|
7
|
+
Session = Struct.new(:page_source) do
|
|
8
|
+
def quit
|
|
9
|
+
puts "closed #{page_source}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def start_driver(**)
|
|
14
|
+
Session.new(device.to_s)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def appium_server_version
|
|
18
|
+
{}
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Appium::Core::Driver.prepend(OfflineSession)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: appium_console
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- code@bootstraponline.com
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 17.0.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 17.0.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: pry
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -92,6 +92,7 @@ files:
|
|
|
92
92
|
- test/cli_test.rb
|
|
93
93
|
- test/console_test.rb
|
|
94
94
|
- test/simple.rb
|
|
95
|
+
- test/support/offline_session.rb
|
|
95
96
|
homepage: https://github.com/appium/ruby_console
|
|
96
97
|
licenses:
|
|
97
98
|
- http://www.apache.org/licenses/LICENSE-2.0.txt
|