appium_lib 9.4.5 → 9.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/appium_lib.gemspec +1 -1
  4. data/docs/android_docs.md +224 -224
  5. data/docs/ios_docs.md +250 -250
  6. data/lib/appium_lib/common/version.rb +1 -1
  7. data/release_notes.md +13 -0
  8. metadata +1 -109
  9. data/android_tests/Gemfile +0 -2
  10. data/android_tests/LICENSE-2.0.txt +0 -202
  11. data/android_tests/Rakefile +0 -68
  12. data/android_tests/api.apk +0 -0
  13. data/android_tests/appium.txt +0 -11
  14. data/android_tests/flaky.txt +0 -1
  15. data/android_tests/lib/android/specs/android/element/alert.rb +0 -48
  16. data/android_tests/lib/android/specs/android/element/button.rb +0 -52
  17. data/android_tests/lib/android/specs/android/element/generic.rb +0 -58
  18. data/android_tests/lib/android/specs/android/element/text.rb +0 -35
  19. data/android_tests/lib/android/specs/android/element/textfield.rb +0 -62
  20. data/android_tests/lib/android/specs/android/helper.rb +0 -111
  21. data/android_tests/lib/android/specs/android/patch.rb +0 -27
  22. data/android_tests/lib/android/specs/common/command.rb +0 -52
  23. data/android_tests/lib/android/specs/common/device.rb +0 -159
  24. data/android_tests/lib/android/specs/common/device_touchaction.rb +0 -34
  25. data/android_tests/lib/android/specs/common/element/window.rb +0 -11
  26. data/android_tests/lib/android/specs/common/helper.rb +0 -112
  27. data/android_tests/lib/android/specs/common/patch.rb +0 -78
  28. data/android_tests/lib/android/specs/common/version.rb +0 -9
  29. data/android_tests/lib/android/specs/common/web_context.rb +0 -60
  30. data/android_tests/lib/android/specs/device/touch_actions.rb +0 -71
  31. data/android_tests/lib/android/specs/driver.rb +0 -280
  32. data/android_tests/lib/android/specs/install.rb +0 -26
  33. data/android_tests/lib/format.rb +0 -47
  34. data/android_tests/lib/run.rb +0 -91
  35. data/android_tests/readme.md +0 -30
  36. data/grid/README.md +0 -21
  37. data/grid/appium.txt.ios.example +0 -15
  38. data/grid/config.json +0 -25
  39. data/grid/hub_config.json +0 -14
  40. data/grid/selenium-server-standalone-2.53.1.jar +0 -0
  41. data/grid/selenium-server-standalone-3.2.0.jar +0 -0
  42. data/ios_tests/Gemfile +0 -4
  43. data/ios_tests/LICENSE-2.0.txt +0 -202
  44. data/ios_tests/Rakefile +0 -54
  45. data/ios_tests/UICatalog.app.zip +0 -0
  46. data/ios_tests/UICatalog.app/12-6AM.png +0 -0
  47. data/ios_tests/UICatalog.app/12-6PM.png +0 -0
  48. data/ios_tests/UICatalog.app/6-12AM.png +0 -0
  49. data/ios_tests/UICatalog.app/6-12PM.png +0 -0
  50. data/ios_tests/UICatalog.app/Default-568h@2x.png +0 -0
  51. data/ios_tests/UICatalog.app/Default@2x.png +0 -0
  52. data/ios_tests/UICatalog.app/Info.plist +0 -0
  53. data/ios_tests/UICatalog.app/PkgInfo +0 -1
  54. data/ios_tests/UICatalog.app/UIButton_custom.png +0 -0
  55. data/ios_tests/UICatalog.app/UICatalog +0 -0
  56. data/ios_tests/UICatalog.app/blueButton.png +0 -0
  57. data/ios_tests/UICatalog.app/bookmarkImage.png +0 -0
  58. data/ios_tests/UICatalog.app/bookmarkImageHighlighted.png +0 -0
  59. data/ios_tests/UICatalog.app/divider.png +0 -0
  60. data/ios_tests/UICatalog.app/en.lproj/AlertsViewController.nib +0 -0
  61. data/ios_tests/UICatalog.app/en.lproj/ButtonsViewController.nib +0 -0
  62. data/ios_tests/UICatalog.app/en.lproj/ControlsViewController.nib +0 -0
  63. data/ios_tests/UICatalog.app/en.lproj/ImagesViewController.nib +0 -0
  64. data/ios_tests/UICatalog.app/en.lproj/Localizable.strings +0 -0
  65. data/ios_tests/UICatalog.app/en.lproj/MainWindow.nib +0 -0
  66. data/ios_tests/UICatalog.app/en.lproj/PickerViewController.nib +0 -0
  67. data/ios_tests/UICatalog.app/en.lproj/SearchBarController.nib +0 -0
  68. data/ios_tests/UICatalog.app/en.lproj/SegmentViewController.nib +0 -0
  69. data/ios_tests/UICatalog.app/en.lproj/TextFieldController.nib +0 -0
  70. data/ios_tests/UICatalog.app/en.lproj/TextViewController.nib +0 -0
  71. data/ios_tests/UICatalog.app/en.lproj/ToolbarViewController.nib +0 -0
  72. data/ios_tests/UICatalog.app/en.lproj/TransitionViewController.nib +0 -0
  73. data/ios_tests/UICatalog.app/en.lproj/WebViewController.nib +0 -0
  74. data/ios_tests/UICatalog.app/orangeslide.png +0 -0
  75. data/ios_tests/UICatalog.app/scene1.jpg +0 -0
  76. data/ios_tests/UICatalog.app/scene2.jpg +0 -0
  77. data/ios_tests/UICatalog.app/scene3.jpg +0 -0
  78. data/ios_tests/UICatalog.app/scene4.jpg +0 -0
  79. data/ios_tests/UICatalog.app/scene5.jpg +0 -0
  80. data/ios_tests/UICatalog.app/searchBarBackground.png +0 -0
  81. data/ios_tests/UICatalog.app/segment_check.png +0 -0
  82. data/ios_tests/UICatalog.app/segment_search.png +0 -0
  83. data/ios_tests/UICatalog.app/segment_tools.png +0 -0
  84. data/ios_tests/UICatalog.app/segmentedBackground.png +0 -0
  85. data/ios_tests/UICatalog.app/slider_ball.png +0 -0
  86. data/ios_tests/UICatalog.app/toolbarBackground.png +0 -0
  87. data/ios_tests/UICatalog.app/whiteButton.png +0 -0
  88. data/ios_tests/UICatalog.app/yellowslide.png +0 -0
  89. data/ios_tests/appium.txt +0 -15
  90. data/ios_tests/data/unicode.txt +0 -1
  91. data/ios_tests/flaky.txt +0 -1
  92. data/ios_tests/lib/common.rb +0 -84
  93. data/ios_tests/lib/format.rb +0 -23
  94. data/ios_tests/lib/ios/specs/common/command.rb +0 -45
  95. data/ios_tests/lib/ios/specs/common/element/window.rb +0 -17
  96. data/ios_tests/lib/ios/specs/common/helper.rb +0 -228
  97. data/ios_tests/lib/ios/specs/common/patch.rb +0 -54
  98. data/ios_tests/lib/ios/specs/common/version.rb +0 -17
  99. data/ios_tests/lib/ios/specs/common/web_context.rb +0 -15
  100. data/ios_tests/lib/ios/specs/device/device.rb +0 -130
  101. data/ios_tests/lib/ios/specs/device/multi_touch.rb +0 -31
  102. data/ios_tests/lib/ios/specs/device/touch_actions.rb +0 -90
  103. data/ios_tests/lib/ios/specs/driver.rb +0 -308
  104. data/ios_tests/lib/ios/specs/ios/element/alert.rb +0 -51
  105. data/ios_tests/lib/ios/specs/ios/element/button.rb +0 -58
  106. data/ios_tests/lib/ios/specs/ios/element/generic.rb +0 -37
  107. data/ios_tests/lib/ios/specs/ios/element/text.rb +0 -63
  108. data/ios_tests/lib/ios/specs/ios/element/textfield.rb +0 -135
  109. data/ios_tests/lib/ios/specs/ios/helper.rb +0 -59
  110. data/ios_tests/lib/ios/specs/ios/mobile_methods.rb +0 -20
  111. data/ios_tests/lib/ios/specs/ios/patch.rb +0 -34
  112. data/ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb +0 -110
  113. data/ios_tests/lib/run.rb +0 -4
  114. data/ios_tests/readme.md +0 -31
  115. data/ios_tests/upload/sauce_storage.rb +0 -67
  116. data/ios_tests/upload/upload.rb +0 -6
@@ -1,54 +0,0 @@
1
- # rubocop:disable Lint/RescueException
2
- # rubocop:disable Metrics/LineLength
3
-
4
- #
5
- # Skip:
6
- # status # status patches are already tested in driver.rb
7
- # raw_execute # debug output for Pry
8
- #
9
-
10
- # rake ios[common/patch]
11
- describe 'common/patch.rb' do
12
- def before_first
13
- screen.must_equal catalog
14
- end
15
-
16
- t 'before_first' do
17
- before_first
18
- end
19
-
20
- # Attributes are busted in Android.
21
- # Blocked on https://github.com/appium/appium/issues/628
22
- describe 'Selenium::WebDriver::Element methods' do
23
- # TODO: t 'value' do; end
24
-
25
- t 'name' do
26
- first_text.name.must_equal 'UICatalog'
27
- end
28
-
29
- # t 'tag_name' do; end # Doesn't work on Android
30
-
31
- t 'location_rel' do
32
- loc = first_text.location_rel
33
- loc.x.class.must_equal String
34
- loc.y.class.must_equal String
35
- end
36
- end
37
-
38
- describe 'common patch' do
39
- # By default, the webdriver gem will return message instead of origValue
40
- # {"message":"An unknown server-side error occurred while processing the command.","origValue":"Strategy id is not valid."}
41
- t 'error_message' do
42
- value = ''
43
- begin
44
- set_wait 0
45
- find_element(:css, 'ok')
46
- rescue Exception => e
47
- value = e.message
48
- ensure
49
- set_wait
50
- end
51
- value.must_equal "Locator Strategy 'css selector' is not supported for this session"
52
- end
53
- end
54
- end
@@ -1,17 +0,0 @@
1
- describe 'version.rb' do
2
- def before_first
3
- screen.must_equal catalog
4
- end
5
-
6
- t 'before_first' do
7
- before_first
8
- end
9
-
10
- t '::Appium::VERSION' do
11
- ::Appium::VERSION.must_match(/(\d+)\.(\d+).(\d+)/)
12
- end
13
-
14
- t '::Appium::DATE' do
15
- ::Appium::DATE.must_match(/(\d+)\-(\d+)\-(\d+)/)
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- # Tests specifically for areas where the web_context differs in behaviour
2
- describe 'the web context' do
3
- t 'get_android_inspect' do
4
- text('Web').click
5
- set_context 'WEBVIEW'
6
- current_context.must_equal 'WEBVIEW_1'
7
- sleep 1 # Give a chance to load
8
- page.start_with?("\nhtml\n").must_equal true
9
- end
10
-
11
- t 'after_last' do
12
- set_context 'NATIVE_APP'
13
- back_click
14
- end
15
- end
@@ -1,130 +0,0 @@
1
- describe 'device/device' do
2
- def before_first
3
- screen.must_equal catalog
4
- end
5
-
6
- # go back to the main page
7
- def go_back
8
- back
9
- wait { !exists { id 'ArrowButton' } } # successfully transitioned back
10
- end
11
-
12
- t 'before_first' do
13
- before_first
14
- end
15
-
16
- t 'device_time' do
17
- Date.parse(device_time)
18
- end
19
-
20
- t 'lock' do
21
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
22
-
23
- lock 5
24
- tag(UI::Inventory.button).name.must_equal 'SlideToUnlock'
25
-
26
- # It appears that lockForDuration doesn't.
27
- close_app
28
- launch_app
29
- end
30
-
31
- t 'background_app' do
32
- background_app 5
33
- screen.must_equal catalog
34
- end
35
-
36
- t 'app_installed' do
37
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
38
-
39
- installed = app_installed? 'Derrp'
40
- installed.must_equal false
41
- end
42
-
43
- t 'shake' do
44
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
45
-
46
- shake
47
- end
48
-
49
- t 'close and launch' do
50
- close_app
51
- launch_app
52
- tag(UI::Inventory.navbar).name.must_equal 'UICatalog'
53
- end
54
-
55
- t 'background_app homescreen' do
56
- background_app(-1) # background_app(nil) should work as same.
57
-
58
- screen.must_equal 'UICatalog'
59
- # TODO: Should update this assert.
60
- # screen.must_raise ::Selenium::WebDriver::Error::NoSuchElementError
61
- end
62
-
63
- t 'reset' do
64
- reset
65
- end
66
-
67
- t 'available_contexts' do
68
- available_contexts.must_equal ['NATIVE_APP']
69
- end
70
-
71
- t 'current_context' do
72
- current_context.must_equal 'NATIVE_APP'
73
- end
74
-
75
- t 'switch_to_default_context' do
76
- switch_to_default_context
77
- current_context.must_equal 'NATIVE_APP'
78
- end
79
-
80
- t 'app_strings' do
81
- app_strings.must_include 'SearchBarExplain'
82
- app_strings('en').must_include 'SearchBarExplain'
83
- end
84
-
85
- t 'action_chain' do
86
- Appium::TouchAction.new.press(element: text(app_strings['ButtonsExplain'])).perform
87
- wait { id 'ArrowButton' } # successfully transitioned to buttons page
88
- go_back
89
- end
90
-
91
- t 'swipe' do
92
- touch_action = Appium::TouchAction.new.swipe(start_x: 75, start_y: 500,
93
- offset_x: 75, offset_y: 20, duration: 500).perform
94
- touch_action.actions.must_equal []
95
-
96
- touch_action = Appium::TouchAction.new.swipe(start_x: 75, start_y: 500, offset_x: 75, offset_y: 20, duration: 500)
97
-
98
- touch_action.actions[0][:action].must_equal :press
99
- touch_action.actions[0][:options].must_equal(x: 75, y: 500)
100
-
101
- touch_action.actions[1][:action].must_equal :wait,
102
- touch_action.actions[1][:options].must_equal(ms: 500)
103
-
104
- touch_action.actions[2][:action].must_equal :moveTo
105
- touch_action.actions[2][:options].must_equal(x: 75, y: 20)
106
-
107
- touch_action.actions[3][:action].must_equal :release
108
-
109
- touch_action.perform
110
- touch_action.actions.must_equal []
111
- end
112
-
113
- t 'pull_file' do
114
- # Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command.
115
- # Original error: Cannot read property 'getDir' of undefined
116
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
117
-
118
- read_file = pull_file 'Library/AddressBook/AddressBook.sqlitedb'
119
- read_file.start_with?('SQLite format').must_equal true
120
- end
121
-
122
- t 'pull_folder' do
123
- # Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command.
124
- # Original error: Cannot read property 'getDir' of undefined
125
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
126
-
127
- data = pull_folder 'Library/AddressBook'
128
- data.length.must_be :>, 1
129
- end
130
- end
@@ -1,31 +0,0 @@
1
- # rake ios[device/multi_touch]
2
- describe 'device/multi_touch' do
3
- def before_first
4
- screen.must_equal catalog
5
- end
6
-
7
- # go back to the main page
8
- def go_back
9
- back
10
- wait { !exists { id 'ArrowButton' } } # successfully transitioned back
11
- end
12
-
13
- t 'before_first' do
14
- before_first
15
- end
16
-
17
- t 'pinch & zoom' do
18
- wait { id('Images').click }
19
- # both of these appear to do nothing on iOS 8
20
- Appium::MultiTouch.zoom 200
21
- Appium::MultiTouch.pinch 75
22
- go_back
23
- end
24
- end
25
-
26
- # TODO: write tests
27
- # pinch
28
- # zoom
29
- # initialize
30
- # add
31
- # perform
@@ -1,90 +0,0 @@
1
- # rake ios[device/touch_actions]
2
- describe 'device/touch_actions' do
3
- def after_last
4
- back_click
5
- end
6
-
7
- t 'swipe_default_duration' do
8
- wait_true do
9
- wait { UI::Inventory.xcuitest? ? find_element(:name, 'Pickers').click : text('pickers').click }
10
- screen == 'Pickers'
11
- end
12
-
13
- ele_index(UI::Inventory.static_text, 2).text.must_equal 'John Appleseed - 0'
14
- picker = ele_index(UI::Inventory.picker, 1)
15
- loc = picker.location.to_h
16
- size = picker.size.to_h
17
- start_x = loc[:x] + size[:width] / 2
18
- start_y = loc[:y] + size[:height] / 2
19
- # rubocop:disable Metrics/LineLength
20
- # Example for iOS's log with XCUITest
21
- # [0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50
22
- # [debug] [WebDriverAgent] Sim: Jan 14 16:35:05 rrcs-172-254-99-35 CoreSimulatorBridge[65868]: KEYMAP: Chose mode=en_US@hw=Automatic;sw=QWERTY from match=en_US@hw=Automatic;sw=QWERTY from language=en
23
- # [HTTP] --> POST /wd/hub/session/cd65fa75-cbd7-4348-a7d6-60cbde28db47/touch/perform {"actions":[{"action":"press","options":{"x":187,"y":201}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}]}
24
- # [debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":187,"y":201}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}],"cd65fa75-cbd7-4348-a7d6-60cbde28db47"]
25
- # [debug] [XCUITest] Executing command 'performTouch'
26
- # [debug] [XCUITest] Received the following touch action: press-wait-moveTo-release
27
- # [debug] [JSONWP Proxy] Proxying [POST /uiaTarget/0/dragfromtoforduration] to [POST http://localhost:8100/session/0D2991FB-A997-4D6C-94FC-D65CC252EC4B/uiaTarget/0/dragfromtoforduration] with body: {"fromX":187,"fromY":201,"toX":187,"toY":151,"duration":0.2}
28
- # [debug] [WebDriverAgent] Sim: Jan 14 16:35:05 rrcs-172-254-99-35 CoreSimulatorBridge[65868]: Switching to keyboard: en
29
- #
30
- # Example for iOS's log with Instruments
31
- # [0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50, duration: 1000
32
- # [HTTP] <-- POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform 200 2048 ms - 74
33
- # [HTTP] --> POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform {"actions":[{"action":"press","options":{"x":187,"y":201.078125}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}]}
34
- # [debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":187,"y":201.078125}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}],"8b651f03-0fbc-43f0-aaf2-243d0650f6aa"]
35
- # [debug] [iOS] Executing iOS command 'performTouch'
36
- # [debug] [UIAuto] Sending command to instruments: au.dragApp(187, 201.078125, 187, 151.078125, 1)
37
- # [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: Got new command 12 from instruments: au.dragApp(187, 201.078125, 187, 151.078125, 1)
38
- # [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: evaluating au.dragApp(187, 201.078125, 187, 151.078125, 1)
39
- # [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: target.dragFromToForDuration({x:"187", y:"201.078125"}, {x:"187", y:"151.078125"}, "1")
40
- # [debug] [Instruments] [INST] 2017-01-14 08:22:58 +0000 Debug: evaluation finished
41
- # [debug] [Instruments] [INST] 2017-01-14 08:22:58 +0000 Debug: responding with:
42
- # [debug] [UIAuto] Socket data received (25 bytes)
43
- # [debug] [UIAuto] Got result from instruments: {"status":0,"value":""}
44
- # [debug] [MJSONWP] Responding to client with driver.performTouch() result: ""
45
- # [HTTP] <-- POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform 200 1895 ms - 74
46
- # rubocop:enable Metrics/LineLength
47
- Appium::TouchAction.new.swipe(start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50).perform
48
- ele_index(UI::Inventory.static_text, 2).text.must_equal 'Chris Armstrong - 0'
49
- end
50
-
51
- t 'swipe_coordinates_end_x_end_y' do
52
- s = Appium::TouchAction.new.swipe_coordinates(offset_x: 1, offset_y: 2)
53
- s[:offset_x].must_equal 1
54
- s[:offset_y].must_equal 2
55
- end
56
-
57
- t 'swipe_coordinates_end_x' do
58
- s = Appium::TouchAction.new.swipe_coordinates(offset_x: 1)
59
- s[:offset_x].must_equal 1
60
- s[:offset_y].must_equal 0
61
- end
62
-
63
- t 'swipe_coordinates_end_y' do
64
- s = Appium::TouchAction.new.swipe_coordinates(offset_y: 1)
65
- s[:offset_x].must_equal 0
66
- s[:offset_y].must_equal 1
67
- end
68
-
69
- t 'swipe_coordinates_offset' do
70
- s = Appium::TouchAction.new.swipe_coordinates
71
- s[:offset_x].must_equal 0
72
- s[:offset_y].must_equal 0
73
- end
74
-
75
- t 'after_last' do
76
- after_last
77
- end
78
- end
79
-
80
- # TODO: write tests
81
- #
82
- # move_to
83
- # long_press
84
- # press
85
- # release
86
- # tap
87
- # wait
88
- # swipe
89
- # perform
90
- # cancel
@@ -1,308 +0,0 @@
1
- # rake ios[driver]
2
- describe 'driver' do
3
- def before_first
4
- screen.must_equal catalog
5
- end
6
-
7
- t 'before_first' do
8
- before_first
9
- end
10
-
11
- def sauce?
12
- ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
13
- end
14
-
15
- t 'unicode defaults' do
16
- data = File.read File.expand_path '../../../../data/unicode.txt', __FILE__
17
- data.strip.must_equal 174.chr('UTF-8')
18
- end
19
-
20
- t 'load_settings' do
21
- # skip this test if we're using Sauce
22
- # the storage API doesn't have an on disk file
23
- skip if sauce?
24
- appium_txt = File.join(Dir.pwd, 'appium.txt')
25
- opts = Appium.load_settings file: appium_txt, verbose: true
26
-
27
- actual = ''
28
- actual = File.basename opts[:caps][:app] if opts && opts[:caps]
29
- expected = 'UICatalog.app'
30
- assert_equal expected, actual
31
- end
32
-
33
- t 'verify Appium::Driver::Capabilities.init_caps_for_appium' do
34
- expected_app = File.absolute_path('UICatalog.app')
35
- caps = ::Appium::Driver::Capabilities.init_caps_for_appium(platformName: 'ios',
36
- platformVersion: '10.3',
37
- automationName: 'XCUITest',
38
- deviceName: 'iPhone Simulator',
39
- app: expected_app,
40
- some_capability: 'some_capability')
41
- caps_with_json = JSON.parse(caps.to_json)
42
- caps_with_json['platformName'].must_equal 'ios'
43
- caps_with_json['platformVersion'].must_equal '10.3'
44
- caps_with_json['app'].must_equal expected_app
45
- caps_with_json['automationName'].must_equal 'XCUITest'
46
- caps_with_json['deviceName'].must_equal 'iPhone Simulator'
47
- caps_with_json['someCapability'].must_equal 'some_capability'
48
-
49
- caps[:platformName].must_equal 'ios'
50
- caps[:platformVersion].must_equal '10.3'
51
- caps[:app].must_equal expected_app
52
- caps[:automationName].must_equal 'XCUITest'
53
- caps[:deviceName].must_equal 'iPhone Simulator'
54
- caps[:some_capability].must_equal 'some_capability'
55
- end
56
-
57
- describe 'Appium::Driver attributes' do
58
- t 'verify all attributes' do
59
- actual = driver_attributes
60
- caps_app_for_teardown = actual[:caps][:app]
61
- expected_app = File.absolute_path('UICatalog.app')
62
-
63
- expected = { automation_name: 'XCUITest',
64
- custom_url: false,
65
- export_session: false,
66
- default_wait: 30,
67
- sauce_username: nil,
68
- sauce_access_key: nil,
69
- sauce_endpoint: 'ondemand.saucelabs.com:443/wd/hub',
70
- port: 4723,
71
- device: :ios,
72
- debug: true,
73
- listener: nil,
74
- wait_timeout: 20, # defined in appium.txt
75
- wait_interval: 1 } # defined in appium.txt
76
-
77
- # actual[:caps].to_json send to Appium server
78
- caps_with_json = JSON.parse(actual[:caps].to_json)
79
- caps_with_json['platformName'].must_equal 'ios'
80
- caps_with_json['platformVersion'].must_equal '10.3'
81
- caps_with_json['app'].must_equal expected_app
82
- caps_with_json['automationName'].must_equal 'XCUITest'
83
- caps_with_json['deviceName'].must_equal 'iPhone Simulator'
84
- caps_with_json['someCapability'].must_equal 'some_capability'
85
-
86
- actual[:caps][:platformName].must_equal 'ios'
87
- actual[:caps][:platformVersion].must_equal '10.3'
88
- actual[:caps][:app].must_equal expected_app
89
- actual[:caps][:automationName].must_equal 'XCUITest'
90
- actual[:caps][:deviceName].must_equal 'iPhone Simulator'
91
- actual[:caps][:some_capability].must_equal 'some_capability'
92
-
93
- dup_actual = actual.dup
94
- dup_actual.delete(:caps)
95
-
96
- if dup_actual != expected
97
- diff = HashDiff.diff expected, actual
98
- diff = "diff (expected, actual):\n#{diff}"
99
-
100
- actual[:caps][:app] = caps_app_for_teardown
101
- # example:
102
- # change :ios in expected to match 'ios' in actual
103
- # [["~", "caps.platformName", :ios, "ios"]]
104
- message = "\n\nactual:\n\n: #{actual.ai}expected:\n\n#{expected.ai}\n\n#{diff}"
105
- raise message
106
- end
107
-
108
- actual_selenium_caps = actual[:caps][:automationName]
109
- actual_selenium_caps.must_equal 'XCUITest'
110
- actual[:caps][:app] = caps_app_for_teardown
111
- end
112
-
113
- t 'verify attributes are immutable' do
114
- driver_attributes[:custom_url] = true
115
- expected = false
116
- driver_attributes[:custom_url].must_equal expected
117
- end
118
-
119
- t 'verify attribute of :caps are not immutable becuse it depends on Selenium' do
120
- # immutability depends on Selenium
121
- for_clean_up = driver_attributes[:caps][:app].dup
122
- driver_attributes[:caps][:app] = 'fake'
123
- expected = 'fake'
124
- driver_attributes[:caps][:app].must_equal expected
125
-
126
- # clean up
127
- driver_attributes[:caps][:app] = for_clean_up
128
- end
129
-
130
- t 'no_wait' do
131
- no_wait
132
- proc { find_element(:accessibility_id, 'zz') }.must_raise Selenium::WebDriver::Error::NoSuchElementError
133
- set_wait
134
- end
135
-
136
- t 'default_wait attr' do
137
- default_wait.must_equal 30
138
- end
139
-
140
- t 'app_path attr' do
141
- apk_name = File.basename driver_attributes[:caps][:app]
142
-
143
- if sauce?
144
- apk_name.must_equal 'sauce-storage:UICatalog6.1.app.zip'
145
- else
146
- apk_name.must_equal 'UICatalog.app'
147
- end
148
- end
149
-
150
- # Only used for Sauce Labs
151
- t 'app_name attr' do
152
- name_attr = driver_attributes[:caps][:name]
153
- if sauce?
154
- name_attr.must_equal 'appium_lib_ios'
155
- else
156
- name_attr.must_be_nil
157
- end
158
- end
159
-
160
- t 'sauce_username attr' do
161
- sauce_username = driver_attributes[:sauce_username]
162
- if sauce?
163
- sauce_username.must_equal 'appiumci'
164
- else
165
- sauce_username.must_be_nil
166
- end
167
- end
168
-
169
- t 'sauce_access_key attr' do
170
- sauce_access_key = driver_attributes[:sauce_access_key]
171
- if sauce?
172
- sauce_access_key.must_match(/\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/)
173
- else
174
- sauce_access_key.must_be_nil
175
- end
176
- end
177
-
178
- t 'default timeout for http client' do
179
- http_client.open_timeout.must_equal 999_999
180
- http_client.read_timeout.must_equal 999_999
181
- end
182
- end
183
-
184
- describe 'Appium::Driver' do
185
- t '$driver.class' do
186
- $driver.class.must_equal Appium::Driver
187
- end
188
- end
189
-
190
- describe 'methods' do
191
- t 'status' do
192
- appium_server_version['build'].keys.sort.must_equal %w(revision version)
193
- end
194
-
195
- t 'server_version' do
196
- server_version = appium_server_version['build']['version']
197
- if sauce?
198
- server_version.must_match 'Sauce OnDemand'
199
- else
200
- server_version.must_match(/(\d+)\.(\d+).(\d+)/)
201
- end
202
- end
203
-
204
- t 'client_version' do
205
- client_version = appium_client_version
206
- expected = { version: ::Appium::VERSION }
207
- client_version.must_equal expected
208
- end
209
-
210
- t 'set_immediate_value' do
211
- go_to_textfields
212
-
213
- message = 'hello'
214
-
215
- element = textfield(1)
216
- element.click
217
- element.clear
218
-
219
- set_immediate_value(element, message)
220
- element.text.must_equal message
221
-
222
- set_wait 10
223
- leave_textfields
224
- end
225
-
226
- t 'restart' do
227
- restart
228
- text 'buttons'
229
- end
230
-
231
- t 'driver' do
232
- driver.browser.must_be_empty
233
- end
234
-
235
- t 'automation_name_is_xcuitest?' do
236
- automation_name_is_xcuitest?.must_equal UI::Inventory.xcuitest?
237
- end
238
-
239
- #
240
- # Skip:
241
- # screenshot # this is slow and already tested by Appium
242
- # driver_quit # tested by restart
243
- # start_driver # tested by restart
244
- #
245
-
246
- t 'set_wait' do
247
- # fill the @last_waits array with: [30, 30]
248
- set_wait(30).must_equal(30)
249
- set_wait(30).must_equal(30)
250
-
251
- # verify set_wait with no args works correctly
252
- set_wait.must_equal(30)
253
- set_wait(30).must_equal(30)
254
- set_wait.must_equal(30)
255
-
256
- set_wait(2).must_equal(2)
257
- set_wait.must_equal(30)
258
- set_wait(3).must_equal(3)
259
- set_wait.must_equal(30)
260
-
261
- set_wait(2).must_equal(2)
262
- set_wait(3).must_equal(3)
263
- set_wait.must_equal(30)
264
- end
265
-
266
- t 'default_wait' do
267
- set_wait 30
268
- default_wait.must_equal 30 # set in run.rb
269
- end
270
-
271
- # returns true unless an error is raised
272
- t 'exists' do
273
- exists(0, 0) { true }.must_equal true
274
- exists(0, 0) { raise 'error' }.must_equal false
275
- end
276
-
277
- # simple integration sanity test to check for unexpected exceptions
278
- t 'set_location' do
279
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
280
- set_location latitude: 55, longitude: -72, altitude: 33
281
- end
282
-
283
- # any elements
284
- t 'find_elements' do
285
- find_elements(:class, UI::Inventory.table_cell).length.must_equal 12
286
- end
287
-
288
- # any element
289
- t 'find_element' do
290
- find_element(:class, UI::Inventory.static_text).class.must_equal Selenium::WebDriver::Element
291
- end
292
-
293
- # settings
294
- t 'get settings' do
295
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
296
- get_settings.wont_be_nil
297
- end
298
-
299
- t 'update settings' do
300
- raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest?
301
-
302
- update_settings cyberdelia: 'open'
303
- get_settings['cyberdelia'].must_equal 'open'
304
- end
305
-
306
- # Skip: x # x is only used in Pry
307
- end
308
- end