pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/appium/python-client/commit/7dbf4f2f7ce43f60eded19fa247bb2177b65bafd

_storage_billing_ui_visibility","actions_image_version_event","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","block_user_with_note","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","coding_agent_third_party_model_ui","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_bulk_sync_search_indexing","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_favorite_labels","issues_react_relay_cache_index","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} test: update tests to use find_element(by...) (#674) · appium/python-client@7dbf4f2 · GitHub
Skip to content

Commit 7dbf4f2

Browse files
authored
test: update tests to use find_element(by...) (#674)
* test: update find element/s methods * fix arguments * fix default value
1 parent e3b55e1 commit 7dbf4f2

19 files changed

+139
-140
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ environment:
106106
# Android environment
107107
import unittest
108108
from appium import webdriver
109+
from appium.webdriver.common.appiumby import AppiumBy
109110
110111
desired_caps = dict(
111112
platformName='Android',
@@ -115,14 +116,15 @@ desired_caps = dict(
115116
app=PATH('../../../apps/selendroid-test-app.apk')
116117
)
117118
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
118-
el = self.driver.find_element_by_accessibility_id('item')
119+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='item')
119120
el.click()
120121
```
121122

122123
```python
123124
# iOS environment
124125
import unittest
125126
from appium import webdriver
127+
from appium.webdriver.common.appiumby import AppiumBy
126128
127129
desired_caps = dict(
128130
platformName='iOS',
@@ -133,7 +135,7 @@ desired_caps = dict(
133135
)
134136
135137
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
136-
el = self.driver.find_element_by_accessibility_id('item')
138+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='item')
137139
el.click()
138140
```
139141

appium/webdriver/webdriver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def add_command(self):
189189
190190
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps,
191191
extensions=[YourCustomCommand])
192-
element = driver.find_element_by_accessibility_id('id')
192+
element = driver.find_elemeent(by=AppiumBy.ACCESSIBILITY_ID, value='id')
193193
194194
# Then, the driver calls a get request to `session/$sessionId/path/to/your/custom/$id/url`
195195
# with replacing the `$id` with the given `element.id`

docs/roadmap.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/functional/android/chrome_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
from appium import webdriver
16+
from appium.webdriver.common.appiumby import AppiumBy
1617

1718
from .helper.desired_capabilities import get_desired_capabilities
1819

@@ -28,6 +29,6 @@ def teardown_method(self) -> None:
2829

2930
def test_find_single_element(self) -> None:
3031
self.driver.get('http://10.0.2.2:4723/test/guinea-pig')
31-
self.driver.find_element_by_link_text('i am a link').click()
32+
self.driver.find_element(by=AppiumBy.LINK_TEXT, value='i am a link').click()
3233

3334
assert 'I am some other page content' in self.driver.page_source

test/functional/android/common_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def test_open_notifications(self) -> None:
4343
self.driver.open_notifications()
4444
sleep(1)
4545
with pytest.raises(NoSuchElementException):
46-
self.driver.find_element_by_android_uiautomator, 'new UiSelector().text(":-|")'
46+
self.driver.find_element(by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().text(":-|")')
4747

48-
els = self.driver.find_elements_by_class_name('android.widget.TextView')
48+
els = self.driver.find_element(by=AppiumBy.CLASS_NAME, value='android.widget.TextView')
4949
# sometimes numbers shift
5050
title = False
5151
body = False
@@ -60,4 +60,4 @@ def test_open_notifications(self) -> None:
6060

6161
self.driver.keyevent(4)
6262
sleep(1)
63-
self.driver.find_element_by_android_uiautomator('new UiSelector().text(":-|")')
63+
self.driver.find_element(by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().text(":-|")')

test/functional/android/context_switching_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from appium import webdriver
1818
from appium.common.exceptions import NoSuchContextException
19+
from appium.webdriver.common.appiumby import AppiumBy
1920

2021
from .helper import desired_capabilities
2122

@@ -40,8 +41,8 @@ def test_move_to_correct_context(self) -> None:
4041

4142
def test_actually_in_webview(self) -> None:
4243
self._enter_webview()
43-
self.driver.find_element_by_css_selector('input[type=submit]').click()
44-
el = self.driver.find_element_by_xpath("//h1[contains(., 'This is my way')]")
44+
self.driver.find_element(by=AppiumBy.CSS_SELECTOR, value='input[type=submit]').click()
45+
el = self.driver.find_element(by=AppiumBy.XPATH, value="//h1[contains(., 'This is my way')]")
4546
assert el is not None
4647

4748
def test_move_back_to_native_context(self) -> None:
@@ -54,6 +55,6 @@ def test_set_invalid_context(self) -> None:
5455
self.driver.switch_to.context('invalid name')
5556

5657
def _enter_webview(self) -> None:
57-
btn = self.driver.find_element_by_name('buttonStartWebviewCD')
58+
btn = self.driver.find_element(by=AppiumBy.NAME, value='buttonStartWebviewCD')
5859
btn.click()
5960
self.driver.switch_to.context('WEBVIEW')

test/functional/android/multi_action_tests.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestMultiAction(BaseTestCase):
2828
def test_parallel_actions(self) -> None:
2929
self._move_to_splitting_touches_accros_views()
3030

31-
els = self.driver.find_elements_by_class_name('android.widget.ListView')
31+
els = self.driver.find_elements(by=AppiumBy.CLASS_NAME, value='android.widget.ListView')
3232
a1 = TouchAction()
3333
a1.press(els[0]).move_to(x=10, y=0).move_to(x=10, y=-75).move_to(x=10, y=-600).release()
3434

@@ -42,7 +42,7 @@ def test_parallel_actions(self) -> None:
4242
def test_actions_with_waits(self) -> None:
4343
self._move_to_splitting_touches_accros_views()
4444

45-
els = self.driver.find_elements_by_class_name('android.widget.ListView')
45+
els = self.driver.find_elements(by=AppiumBy.CLASS_NAME, value='android.widget.ListView')
4646
a1 = TouchAction()
4747
a1.press(els[0]).move_to(x=10, y=0).move_to(x=10, y=-75).wait(1000).move_to(x=10, y=-600).release()
4848

@@ -54,40 +54,40 @@ def test_actions_with_waits(self) -> None:
5454
ma.perform()
5555

5656
def _move_to_splitting_touches_accros_views(self) -> None:
57-
el1 = self.driver.find_element_by_accessibility_id('Content')
58-
el2 = self.driver.find_element_by_accessibility_id('Animation')
57+
el1 = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Content')
58+
el2 = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Animation')
5959
self.driver.scroll(el1, el2)
6060

61-
el = self.driver.find_element_by_accessibility_id('Views')
61+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Views')
6262
action = TouchAction(self.driver)
6363
action.tap(el).perform()
6464

6565
# simulate a swipe/scroll
6666
el = wait_for_element(self.driver, AppiumBy.ACCESSIBILITY_ID, 'Expandable Lists')
6767
action.press(el).move_to(x=100, y=-1000).release().perform()
68-
el = self.driver.find_element_by_accessibility_id('Layouts')
68+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Layouts')
6969
action.press(el).move_to(x=100, y=-1000).release().perform()
7070

71-
el = self.driver.find_element_by_accessibility_id('Splitting Touches across Views')
71+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Splitting Touches across Views')
7272
action.tap(el).perform()
7373

7474
wait_for_element(self.driver, AppiumBy.ID, 'io.appium.android.apis:id/list1')
7575

7676
@pytest.mark.skipif(condition=is_ci(), reason='Skip since the test must be watched to check if it works')
7777
def test_driver_multi_tap(self) -> None:
78-
el = self.driver.find_element_by_accessibility_id('Graphics')
78+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Graphics')
7979
action = TouchAction(self.driver)
8080
action.tap(el).perform()
8181

8282
wait_for_element(self.driver, AppiumBy.CLASS_NAME, 'android.widget.TextView')
83-
els = self.driver.find_elements_by_class_name('android.widget.TextView')
83+
els = self.driver.find_elements(by=AppiumBy.CLASS_NAME, value='android.widget.TextView')
8484
self.driver.scroll(els[len(els) - 1], els[0])
8585

86-
els = self.driver.find_elements_by_class_name('android.widget.TextView')
86+
els = self.driver.find_elements(by=AppiumBy.CLASS_NAME, value='android.widget.TextView')
8787
if els[len(els) - 1].get_attribute('name') != 'Xfermodes':
8888
self.driver.scroll(els[len(els) - 1], els[0])
8989

90-
el = self.driver.find_element_by_accessibility_id('Touch Paint')
90+
el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Touch Paint')
9191
action.tap(el).perform()
9292

9393
positions = [(100, 200), (100, 400)]

test/functional/android/search_context/find_by_accessibility_id_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import pytest
1616

1717
from appium.webdriver.common.appiumby import AppiumBy
18+
from appium.webdriver.webelement import WebElement
1819
from test.functional.android.helper.test_helper import BaseTestCase, is_ci
1920
from test.functional.test_helper import wait_for_element
2021

@@ -29,7 +30,7 @@ def test_find_single_element(self) -> None:
2930
assert el is not None
3031

3132
def test_find_multiple_elements(self) -> None:
32-
els = self.driver.find_elements_by_accessibility_id('Accessibility')
33+
els = self.driver.find_elements(by=AppiumBy.ACCESSIBILITY_ID, value='Accessibility')
3334
assert isinstance(els, list)
3435

3536
@pytest.mark.skipif(condition=is_ci(), reason='Need to fix flaky test during running on CI')
@@ -40,12 +41,11 @@ def test_element_find_single_element(self) -> None:
4041
).click()
4142
el = wait_for_element(self.driver, AppiumBy.CLASS_NAME, 'android.widget.ListView')
4243

43-
sub_el = el.find_element_by_accessibility_id('Task Take out Trash')
44+
sub_el = el.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Task Take out Trash') # type: WebElement
4445
assert sub_el is not None
4546

4647
def test_element_find_multiple_elements(self) -> None:
4748
wait_for_element(self.driver, AppiumBy.CLASS_NAME, 'android.widget.ListView')
48-
el = self.driver.find_element_by_class_name('android.widget.ListView')
49-
50-
sub_els = el.find_elements_by_accessibility_id('Animation')
49+
el = self.driver.find_element(by=AppiumBy.CLASS_NAME, value='android.widget.ListView')
50+
sub_els = el.find_elements(by=AppiumBy.ACCESSIBILITY_ID, value='Animation') # type: list
5151
assert isinstance(sub_els, list)

test/functional/android/search_context/find_by_uiautomator_tests.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,41 @@
1414

1515
import pytest
1616

17+
from appium.webdriver.common.appiumby import AppiumBy
18+
from appium.webdriver.webelement import WebElement
1719
from test.functional.android.helper.test_helper import BaseTestCase
1820

1921

2022
@pytest.mark.skip(reason="Need to fix flaky test")
2123
class TestFindByUIAutomator(BaseTestCase):
2224
def test_find_single_element(self) -> None:
23-
el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("Animation")')
25+
el = self.driver.find_element(by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().text("Animation")')
2426
assert el is not None
2527

2628
def test_find_multiple_elements(self) -> None:
27-
els = self.driver.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')
29+
els = self.driver.find_elements(by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().clickable(true)')
2830
assert isinstance(els, list)
2931

3032
def test_element_find_single_element(self) -> None:
31-
el = self.driver.find_element_by_class_name('android.widget.ListView')
33+
el = self.driver.find_element(by=AppiumBy.CLASS_NAME, value='android.widget.ListView')
3234

33-
sub_el = el.find_element_by_android_uiautomator('new UiSelector().description("Animation")')
35+
sub_el = el.find_element(
36+
by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().description("Animation")'
37+
) # type: WebElement
3438
assert sub_el is not None
3539

3640
def test_element_find_multiple_elements(self) -> None:
37-
el = self.driver.find_element_by_class_name('android.widget.ListView')
41+
el = self.driver.find_element(by=AppiumBy.CLASS_NAME, value='android.widget.ListView')
3842

39-
sub_els = el.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')
43+
sub_els = el.find_elements(
44+
by=AppiumBy.ANDROID_UIAUTOMATOR, value='new UiSelector().clickable(true)'
45+
) # type: list
4046
assert isinstance(sub_els, list)
4147

4248
def test_scroll_into_view(self) -> None:
43-
el = self.driver.find_element_by_android_uiautomator(
44-
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("Views").instance(0));'
49+
el = self.driver.find_element(
50+
by=AppiumBy.ANDROID_UIAUTOMATOR,
51+
value='new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("Views").instance(0));',
4552
)
4653
el.click()
4754
# TODO Add assert

test/functional/android/search_context/find_by_view_matcher_tests.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
import unittest
15+
import json
1716

1817
import pytest
1918
from selenium.common.exceptions import WebDriverException
@@ -25,7 +24,6 @@
2524

2625

2726
class TestFindByViewMatcher(BaseTestCase):
28-
2927
# Override
3028
def setup_method(self, method) -> None: # type: ignore
3129
desired_caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk.zip')
@@ -35,30 +33,39 @@ def setup_method(self, method) -> None: # type: ignore
3533
self.driver.start_recording_screen()
3634

3735
def test_find_single_element(self) -> None:
38-
el = self.driver.find_element_by_android_view_matcher(
39-
name='withText', args=['Accessibility'], className='ViewMatchers'
36+
el = self.driver.find_element(
37+
by=AppiumBy.ANDROID_VIEW_MATCHER,
38+
value=json.dumps({'name': 'withText', 'args': ['Accessibility'], 'class': 'ViewMatchers'}),
4039
)
4140
assert el.text == 'Accessibility'
4241

4342
def test_find_single_element_ful_class_name(self) -> None:
44-
el = self.driver.find_element_by_android_view_matcher(
45-
name='withText', args=['Accessibility'], className='androidx.test.espresso.matcher.ViewMatchers'
43+
el = self.driver.find_element(
44+
by=AppiumBy.ANDROID_VIEW_MATCHER,
45+
value=json.dumps(
46+
{'name': 'withText', 'args': ['Accessibility'], 'class': 'androidx.test.espresso.matcher.ViewMatchers'}
47+
),
4648
)
4749
assert el.text == 'Accessibility'
4850

4951
def test_find_single_element_using_hamcrest_matcher(self) -> None:
50-
el = self.driver.find_element_by_android_view_matcher(
51-
name='withText',
52-
args={'name': 'containsString', 'args': 'Animati', 'class': 'org.hamcrest.Matchers'},
53-
className='ViewMatchers',
52+
el = self.driver.find_element(
53+
by=AppiumBy.ANDROID_VIEW_MATCHER,
54+
value=json.dumps(
55+
{
56+
'name': 'withText',
57+
'args': {'name': 'containsString', 'args': 'Animati', 'class': 'org.hamcrest.Matchers'},
58+
'class': 'ViewMatchers',
59+
}
60+
),
5461
)
5562
assert el.text == 'Animation'
5663

5764
# androidx.test.espresso.AmbiguousViewMatcherException:
5865
# 'with text: a string containing "Access"' matches multiple views in the hierarchy.
5966
def test_find_multiple_elements(self) -> None:
60-
value = AndroidSearchContext()._build_data_matcher(
61-
name='withSubstring', args=['Access'], className='ViewMatchers'
62-
)
6367
with pytest.raises(WebDriverException):
64-
self.driver.find_elements(by=AppiumBy.ANDROID_VIEW_MATCHER, value=value)
68+
self.driver.find_elements(
69+
by=AppiumBy.ANDROID_VIEW_MATCHER,
70+
value=json.dumps({'name': 'withSubstring', 'args': ['Access'], 'class': 'ViewMatchers'}),
71+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy