Skip to content

Commit 634d003

Browse files
authored
tweak include (#105)
* tweak include * update tests * tweak
1 parent 83ae6f1 commit 634d003

File tree

7 files changed

+50
-19
lines changed

7 files changed

+50
-19
lines changed

lib/appium_lib_core.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
require_relative 'appium_lib_core/version'
44
require_relative 'appium_lib_core/common'
5-
require_relative 'appium_lib_core/patch'
65
require_relative 'appium_lib_core/driver'
76

87
require_relative 'appium_lib_core/device'
@@ -14,6 +13,9 @@
1413
require_relative 'appium_lib_core/ios'
1514
require_relative 'appium_lib_core/ios_xcuitest'
1615

16+
# Call patch after requiring other files
17+
require_relative 'appium_lib_core/patch'
18+
1719
module Appium
1820
# convert all keys (including nested) to symbols
1921
#

test/unit/android/device/mjsonwp/definition_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ def test_with_arg_definitions
8080
:get_clipboard,
8181
:set_clipboard])
8282
end
83+
84+
def test_search_context_in_element_class_for_android
85+
assert_equal '-android uiautomator', ::Selenium::WebDriver::Element::FINDERS[:uiautomator]
86+
end
8387
end
8488
end # module MJSONWP
8589
end # module Device

test/unit/android/device/w3c/commands_test.rb

+16
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,22 @@ def test_ime_deactivate
801801

802802
assert_requested(:post, "#{SESSION}/ime/deactivate", times: 1)
803803
end
804+
805+
def test_search_element_child_element
806+
stub_request(:post, "#{SESSION}/element")
807+
.with(body: { using: 'accessibility id', value: 'example' }.to_json)
808+
.to_return(headers: HEADER, status: 200, body: { value: { ELEMENT: 'element_id_parent' },
809+
sessionId: SESSION, status: 0 }.to_json)
810+
stub_request(:post, "#{SESSION}/element/element_id_parent/element")
811+
.with(body: { using: 'accessibility id', value: 'example2' }.to_json)
812+
.to_return(headers: HEADER, status: 200, body: { value: { ELEMENT: 'element_id_children' },
813+
sessionId: SESSION, status: 0 }.to_json)
814+
815+
@driver.find_element(:accessibility_id, 'example').find_element(:accessibility_id, 'example2')
816+
817+
assert_requested(:post, "#{SESSION}/element", times: 1)
818+
assert_requested(:post, "#{SESSION}/element/element_id_parent/element", times: 1)
819+
end
804820
end # class CommandsTest
805821
end # module W3C
806822
end # module Device

test/unit/android/device/w3c/definition_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def test_with_arg_definitions
7979
:get_clipboard,
8080
:set_clipboard])
8181
end
82+
83+
def test_search_context_in_element_class_for_android
84+
assert_equal '-android uiautomator', ::Selenium::WebDriver::Element::FINDERS[:uiautomator]
85+
end
8286
end # class DefinitionTest
8387
end # module W3C
8488
end # module Device

test/unit/driver_test.rb

+11-18
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,17 @@ def test_default_timeout_for_http_client
8282
end
8383

8484
def test_search_context_in_element_class
85-
expected = {
86-
class: 'class name',
87-
class_name: 'class name',
88-
css: 'css selector',
89-
id: 'id',
90-
link: 'link text',
91-
link_text: 'link text',
92-
name: 'name',
93-
partial_link_text: 'partial link text',
94-
tag_name: 'tag name',
95-
xpath: 'xpath',
96-
accessibility_id: 'accessibility id',
97-
uiautomation: '-ios uiautomation',
98-
predicate: '-ios predicate string',
99-
class_chain: '-ios class chain',
100-
uiautomator: '-android uiautomator'
101-
}
102-
assert_equal expected, ::Selenium::WebDriver::Element::FINDERS
85+
assert_equal 'class name', ::Selenium::WebDriver::Element::FINDERS[:class]
86+
assert_equal 'class name', ::Selenium::WebDriver::Element::FINDERS[:class_name]
87+
assert_equal 'css selector', ::Selenium::WebDriver::Element::FINDERS[:css]
88+
assert_equal 'id', ::Selenium::WebDriver::Element::FINDERS[:id]
89+
assert_equal 'link text', ::Selenium::WebDriver::Element::FINDERS[:link]
90+
assert_equal 'link text', ::Selenium::WebDriver::Element::FINDERS[:link_text]
91+
assert_equal 'name', ::Selenium::WebDriver::Element::FINDERS[:name]
92+
assert_equal 'partial link text', ::Selenium::WebDriver::Element::FINDERS[:partial_link_text]
93+
assert_equal 'tag name', ::Selenium::WebDriver::Element::FINDERS[:tag_name]
94+
assert_equal 'xpath', ::Selenium::WebDriver::Element::FINDERS[:xpath]
95+
assert_equal 'accessibility id', ::Selenium::WebDriver::Element::FINDERS[:accessibility_id]
10396
end
10497
end
10598
end

test/unit/ios/device/mjsonwp/definition_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def test_with_arg_definitions
6767
:touch_id,
6868
:toggle_touch_id_enrollment])
6969
end
70+
71+
def test_search_context_in_element_class_ios
72+
assert_equal '-ios uiautomation', ::Selenium::WebDriver::Element::FINDERS[:uiautomation]
73+
assert_equal '-ios predicate string', ::Selenium::WebDriver::Element::FINDERS[:predicate]
74+
assert_equal '-ios class chain', ::Selenium::WebDriver::Element::FINDERS[:class_chain]
75+
end
7076
end # class DefinitionTest
7177
end # module MJSONWP
7278
end # module Device

test/unit/ios/device/w3c/definition_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ def test_with_arg_definitions
7070
:touch_id,
7171
:toggle_touch_id_enrollment])
7272
end
73+
74+
def test_search_context_in_element_class_ios
75+
assert_equal '-ios uiautomation', ::Selenium::WebDriver::Element::FINDERS[:uiautomation]
76+
assert_equal '-ios predicate string', ::Selenium::WebDriver::Element::FINDERS[:predicate]
77+
assert_equal '-ios class chain', ::Selenium::WebDriver::Element::FINDERS[:class_chain]
78+
end
7379
end # class DefinitionTest
7480
end # module W3C
7581
end # module Device

0 commit comments

Comments
 (0)