Skip to content

Use new complex_find method. #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2014
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
2 changes: 1 addition & 1 deletion android_tests/lib/android/specs/common/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
end

t 'complex_find' do
act = complex_find [[3, 'Accessibility'], [14, true]]
act = complex_find [[[3, 'Accessibility'], [14, true]]]
act.class.must_equal Selenium::WebDriver::Element
end

Expand Down
8 changes: 4 additions & 4 deletions lib/appium_lib/android/element/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ def finds_exact value
# @param text [String] the text to search for in the text value and content description
# @return [Element] the element scrolled to
def scroll_to text
args = 'scroll',
args =
# textContains(text)
[[3, text]],
# descriptionContains(text)
[[7, text]]

complex_find args
complex_find 'scroll', args
end

# Scroll to an element with the exact target text or description.
# @param text [String] the text to search for in the text value and content description
# @return [Element] the element scrolled to
def scroll_to_exact text
args = 'scroll',
args =
# text(text)
[[1, text]],
# description(text)
[[5, text]]

complex_find args
complex_find 'scroll', args
end
end # module Android
end # module Appium
18 changes: 9 additions & 9 deletions lib/appium_lib/device/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ module Device
# of arrays, each containing a selector and that selector's value.
#
# ```ruby
# complex_find [[2, 'Sau'], [14, true]] # => Find a clickable element
# # whose names starts with 'Sau'
# complex_find [[[2, 'Sau'], [14, true]]] # => Find a clickable element
# # whose names starts with 'Sau'
# ```
# @param all (Symbol) If not falsy, will use the 'all' option in your find
# @param mod (Symbol) If present, will be the 0th element in the selector array.
# @param selectors (Array<Object>) The selectors to find elements with.

# @!method hide_keyboard
Expand Down Expand Up @@ -140,17 +140,17 @@ def key_event(key, metastate=nil)
end

add_endpoint_method(:complex_find, 'session/:session_id/appium/app/complex_find') do
def complex_find(all, selectors=nil)
def complex_find(mode, selectors=nil)
if selectors.nil?
selectors = all.dup
all = false
selectors = mod.dup
mod = false
end

selector_array = all ? ['all'] : []
selector_array = mod ? [mod] : []
selector_array.push selectors

ids = execute :complex_find, {}, [selectors]
if all && ids.length > 1
ids = execute :complex_find, {}, selectors
if mod && ids.length > 1

return ids.map { |id| Selenium::WebDriver::Element.new self, element_id_from(id) }
else
Expand Down
2 changes: 1 addition & 1 deletion lib/appium_lib/ios/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Appium
module Appium
module Ios
# iOS only. On Android uiautomator always returns an empty string for EditText password.
#
Expand Down