Skip to content

Commit a8b94c0

Browse files
committed
update documentation and comments
1 parent 17bf48a commit a8b94c0

File tree

3 files changed

+61
-21
lines changed

3 files changed

+61
-21
lines changed

README.md

+36-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
- http://www.rubydoc.info/github/appium/ruby_lib_core
88

9-
# base library
9+
# Used main library
1010
- https://github.com/appium/ruby_lib
1111

1212
# How to start
@@ -18,13 +18,47 @@ $ appium
1818
```
1919

2020
## Run tests
21+
### Unit Tests
2122

2223
```bash
2324
$ bundle install
24-
$ rake test:func:android # Andorid
25+
$ rake test:unit
26+
```
27+
28+
### Functional Tests
29+
30+
```bash
31+
$ bundle install
32+
$ rake test:func:android # Andorid
2533
$ rake test:func:ios # iOS
2634
```
2735

36+
# How to use this core library
37+
1. Launch the appium server locally.
38+
2. Run the following script.
39+
40+
```ruby
41+
require 'rubygems'
42+
require 'appium_lib_core'
43+
44+
opts = {
45+
caps: {
46+
platformName: :ios,
47+
platformVersion: '11.0',
48+
deviceName: 'iPhone Simulator',
49+
automationName: 'XCUITest',
50+
app: '/path/to/MyiOS.app'
51+
},
52+
appium_lib: {
53+
}
54+
}
55+
@core = Appium::Driver.new(opts) # core driver
56+
@driver = @core.start_driver # driver extend selenium-webdriver
57+
58+
# Launch iPhone Simulator and `MyiOS.app`
59+
@driver.find_element(:accessibility_id, 'some accessibility') # find an element
60+
```
61+
2862
# Release
2963

3064
```bash

lib/appium_lib_core/driver.rb

+22-19
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,42 @@ class Driver
1818
# @return [Hash]
1919
attr_reader :automation_name
2020

21-
# Custom URL for the selenium server. If set this attribute, ruby_lib try to handshake to the custom url.
21+
# Custom URL for the selenium server. If set this attribute, ruby_lib_core try to handshake to the custom url.
22+
# False is by default and then "http://127.0.0.1:#{@port}/wd/hub" is used.
2223
# @return [String]
2324
attr_reader :custom_url
2425

25-
# Export session id to textfile in /tmp for 3rd party tools
26+
# Export session id to textfile in /tmp for 3rd party tools. False bu default.
2627
# @return [Boolean]
2728
attr_reader :export_session
2829
# @return [String] By default, session id is exported in '/tmp/appium_lib_session'
2930
attr_reader :export_session_path
3031

3132
# Default wait time for elements to appear
32-
# Returns the default client side wait.
33-
# This value is independent of what the server is using
34-
# Provide Appium::Drive like { appium_lib: { wait: 20 } }
33+
# Returns the default client side wait. 20 second is by default.
34+
# Provide Appium::Drive like { appium_lib: { wait: 30 } }
3535
# @return [Integer]
3636
attr_reader :default_wait
3737

38-
# Appium's server port
38+
# Appium's server port. 4723 is by default.
3939
# Provide Appium::Drive like { appium_lib: { port: 8080 } }
4040
# @return [Integer]
4141
attr_reader :port
4242

43-
# Return a time wait timeout
43+
# Return a time wait timeout. 30 second is by default.
4444
# Wait time for ::Appium::Core::Base::Wait, wait and wait_true
4545
# Provide Appium::Drive like { appium_lib: { wait_timeout: 20 } }
4646
# @return [Integer]
4747
attr_reader :wait_timeout
4848

49-
# Return a time wait timeout
49+
# Return a time to wait interval. 0.5 second is by default.
5050
# Wait interval time for ::Appium::Core::Base::Wait, wait and wait_true
51-
# Provide Appium::Drive like { appium_lib: { wait_interval: 20 } }
51+
# Provide Appium::Drive like { appium_lib: { wait_interval: 0.1 } }
5252
# @return [Integer]
5353
attr_reader :wait_interval
5454

5555
# instance of AbstractEventListener for logging support
56+
# Nil by default
5657
attr_reader :listener
5758

5859
# @return [Appium::Core::Base::Driver]
@@ -66,12 +67,15 @@ class Driver
6667
# @example
6768
#
6869
# require 'rubygems'
69-
# require 'appium_lib'
70+
# require 'appium_lib_core'
7071
#
7172
# # Start iOS driver
7273
# opts = {
7374
# caps: {
7475
# platformName: :ios,
76+
# platformVersion: '11.0',
77+
# deviceName: 'iPhone Simulator',
78+
# automationName: 'XCUITest',
7579
# app: '/path/to/MyiOS.app'
7680
# },
7781
# appium_lib: {
@@ -84,8 +88,8 @@ class Driver
8488
# listener: nil,
8589
# }
8690
# }
87-
# @core_driver = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self`
88-
# @core_driver.start_driver(server_url: server_url, http_client_ops: http_client_ops) # start driver
91+
# @core = Appium::Core.for(self, opts) # create a core driver with `opts` and extend methods into `self`
92+
# @core.start_driver(server_url: server_url) # start driver
8993
#
9094
def self.for(target, opts = {})
9195
new(target, opts)
@@ -120,24 +124,23 @@ def initialize(target, opts = {})
120124
# @example
121125
#
122126
# require 'rubygems'
123-
# require 'appium_lib'
127+
# require 'appium_lib_core'
124128
#
125129
# # platformName takes a string or a symbol.
126130
#
127131
# # Start iOS driver
128132
# opts = {
129133
# caps: {
130134
# platformName: :ios,
135+
# platformVersion: '11.0',
136+
# deviceName: 'iPhone Simulator',
137+
# automationName: 'XCUITest',
131138
# app: '/path/to/MyiOS.app'
132139
# },
133140
# appium_lib: {
134-
# server_url: "http://custom-host:8080/wd/hub.com",
135-
# export_session: false,
136-
# port: 8080,
137-
# wait: 0,
141+
# wait: 20,
138142
# wait_timeout: 20,
139143
# wait_interval: 0.3,
140-
# listener: nil,
141144
# }
142145
# }
143146
# @core = Appium::Driver.new(opts)
@@ -407,7 +410,7 @@ def set_app_path
407410
# @private
408411
def set_appium_lib_specific_values(appium_lib_opts)
409412
@custom_url = appium_lib_opts.fetch :server_url, false
410-
@default_wait = appium_lib_opts.fetch :wait, 0
413+
@default_wait = appium_lib_opts.fetch :wait, 20
411414

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

test/test_helper.rb

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
class AppiumLibCoreTest
1212
module Caps
13+
# Require a simulator which OS version is 10.3, for example.
1314
IOS_OPS = {
1415
caps: {
1516
platformName: :ios,
@@ -28,6 +29,8 @@ module Caps
2829
}
2930
}.freeze
3031

32+
# Require a real device or an emulator.
33+
# We should update platformVersion and deviceName to fit your environment.
3134
ANDROID_OPS = {
3235
caps: {
3336
platformName: :android,

0 commit comments

Comments
 (0)