Skip to content

Commit 893c714

Browse files
authored
Remove appium suffix from find element (#532)
* update find_element/s * add some examples * update migration * remove appium surfix * remove pry * update migration.md * fix some tests
1 parent 61ee15c commit 893c714

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

docs/migration.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
### Breaking Changes in 9.3.7
2+
change `@selenium_driver.find_element/s_with_appium` to `@selenium_driver.find_element/s`.
3+
ref: https://github.com/appium/ruby_lib/pull/532
4+
5+
A breaking change in v9.1.0 is reverted in this version.
6+
7+
Old | New
8+
:--|:--
9+
`@selenium_driver.find_element/s_with_appium` | `@selenium_driver.find_element/s`
10+
11+
- after
12+
13+
```
14+
@selenium_driver.find_element :accessibility_id, "some ids"
15+
@selenium_driver.find_elements :accessibility_id, "some ids"
16+
```
17+
18+
- before
19+
20+
```
21+
@selenium_driver.find_element_with_appium :accessibility_id, "some ids"
22+
@selenium_driver.find_elements_with_appium :accessibility_id, "some ids"
23+
```
24+
25+
126
### Breaking Changes in 9.1.0
227
change `@selenium_driver.find_element/s` to `@selenium_driver.find_element/s_with_appium`.
328
ref: https://github.com/appium/ruby_lib/pull/383

ios_tests/appium.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[caps]
22
platformName = "ios"
3-
platformVersion = "10.2"
3+
platformVersion = "10.3"
44
deviceName ="iPhone Simulator"
55
automationName = 'XCUITest'
66
app = "./UICatalog.app"

ios_tests/lib/ios/specs/driver.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ def sauce?
3333
t 'verify Appium::Driver::Capabilities.init_caps_for_appium' do
3434
expected_app = File.absolute_path('UICatalog.app')
3535
caps = ::Appium::Driver::Capabilities.init_caps_for_appium(platformName: 'ios',
36-
platformVersion: '10.2',
36+
platformVersion: '10.3',
3737
automationName: 'XCUITest',
3838
deviceName: 'iPhone Simulator',
3939
app: expected_app,
4040
some_capability: 'some_capability')
4141
caps_with_json = JSON.parse(caps.to_json)
4242
caps_with_json['platformName'].must_equal 'ios'
43-
caps_with_json['platformVersion'].must_equal '10.2'
43+
caps_with_json['platformVersion'].must_equal '10.3'
4444
caps_with_json['app'].must_equal expected_app
4545
caps_with_json['automationName'].must_equal 'XCUITest'
4646
caps_with_json['deviceName'].must_equal 'iPhone Simulator'
4747
caps_with_json['someCapability'].must_equal 'some_capability'
4848

4949
caps[:platformName].must_equal 'ios'
50-
caps[:platformVersion].must_equal '10.2'
50+
caps[:platformVersion].must_equal '10.3'
5151
caps[:app].must_equal expected_app
5252
caps[:automationName].must_equal 'XCUITest'
5353
caps[:deviceName].must_equal 'iPhone Simulator'
@@ -77,14 +77,14 @@ def sauce?
7777
# actual[:caps].to_json send to Appium server
7878
caps_with_json = JSON.parse(actual[:caps].to_json)
7979
caps_with_json['platformName'].must_equal 'ios'
80-
caps_with_json['platformVersion'].must_equal '10.2'
80+
caps_with_json['platformVersion'].must_equal '10.3'
8181
caps_with_json['app'].must_equal expected_app
8282
caps_with_json['automationName'].must_equal 'XCUITest'
8383
caps_with_json['deviceName'].must_equal 'iPhone Simulator'
8484
caps_with_json['someCapability'].must_equal 'some_capability'
8585

8686
actual[:caps][:platformName].must_equal 'ios'
87-
actual[:caps][:platformVersion].must_equal '10.2'
87+
actual[:caps][:platformVersion].must_equal '10.3'
8888
actual[:caps][:app].must_equal expected_app
8989
actual[:caps][:automationName].must_equal 'XCUITest'
9090
actual[:caps][:deviceName].must_equal 'iPhone Simulator'

lib/appium_lib/device/device.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def create_bridge_command(method)
433433
# ```
434434
def extend_search_contexts
435435
Selenium::WebDriver::SearchContext.class_eval do
436-
def find_element_with_appium(*args)
436+
def find_element(*args)
437437
how, what = extract_args(args)
438438
by = _set_by_from_finders(how)
439439
begin
@@ -443,7 +443,7 @@ def find_element_with_appium(*args)
443443
end
444444
end
445445

446-
def find_elements_with_appium(*args)
446+
def find_elements(*args)
447447
how, what = extract_args(args)
448448
by = _set_by_from_finders(how)
449449
begin

lib/appium_lib/driver.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,20 @@ def execute_script(script, *args)
697697
#
698698
# If you call `Appium.promote_appium_methods`, you can call `find_elements` directly.
699699
#
700+
# ```
701+
# @driver = Appium::Driver.new()
702+
# @driver.find_elements :predicate, yyy
703+
# ```
704+
#
705+
# If you call `Appium.promote_appium_methods`, you can call `find_elements` directly.
706+
#
700707
# @param [*args] args The args to use
701708
# @return [Array<Element>] Array is empty when no elements are found.
702709
def find_elements(*args)
703-
@driver.find_elements_with_appium(*args)
710+
@driver.find_elements(*args)
704711
end
705712

706-
# Calls @driver.find_element_with_appium
713+
# Calls @driver.find_element
707714
#
708715
# ```
709716
# @driver = Appium::Driver.new()
@@ -715,7 +722,7 @@ def find_elements(*args)
715722
# @param [*args] args The args to use
716723
# @return [Element]
717724
def find_element(*args)
718-
@driver.find_element_with_appium(*args)
725+
@driver.find_element(*args)
719726
end
720727

721728
# Calls @driver.set_location

lib/appium_lib/ios/helper.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def find_eles_by_predicate(class_name: '*', value:)
295295
%(type == "#{class_name}" && ) +
296296
%((name ==[c] "#{value}" || label ==[c] "#{value}" || value ==[c] "#{value}"))
297297
end
298-
@driver.find_elements_with_appium :predicate, predicate
298+
@driver.find_elements :predicate, predicate
299299
end
300300

301301
# Get the first tag by attribute that exactly matches value.
@@ -340,7 +340,7 @@ def find_eles_by_predicate_include(class_name: '*', value:)
340340
%(type == "#{class_name}" && ) +
341341
%((name contains[c] "#{value}" || label contains[c] "#{value}" || value contains[c] "#{value}"))
342342
end
343-
@driver.find_elements_with_appium :predicate, predicate
343+
@driver.find_elements :predicate, predicate
344344
end
345345

346346
# Get the first tag that matches class_name
@@ -408,7 +408,7 @@ def tags_include(class_names:, value: nil)
408408
c_names
409409
end
410410

411-
elements = @driver.find_elements_with_appium :predicate, predicate
411+
elements = @driver.find_elements :predicate, predicate
412412
select_visible_elements elements
413413
else
414414
class_names.flat_map do |class_name|
@@ -437,7 +437,7 @@ def tags_exact(class_names:, value: nil)
437437
c_names
438438
end
439439

440-
elements = @driver.find_elements_with_appium :predicate, predicate
440+
elements = @driver.find_elements :predicate, predicate
441441
select_visible_elements elements
442442
else
443443
class_names.flat_map do |class_name|

0 commit comments

Comments
 (0)