Skip to content
Closed
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
1 change: 1 addition & 0 deletions appium/webdriver/common/mobileby.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ class MobileBy(By):
IOS_UIAUTOMATION = '-ios uiautomation'
ANDROID_UIAUTOMATOR = '-android uiautomator'
ACCESSIBILITY_ID = 'accessibility id'
IOS_PREDICATE_STRING = '-ios predicate string'
23 changes: 23 additions & 0 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
By.IOS_UIAUTOMATION = MobileBy.IOS_UIAUTOMATION
By.ANDROID_UIAUTOMATOR = MobileBy.ANDROID_UIAUTOMATOR
By.ACCESSIBILITY_ID = MobileBy.ACCESSIBILITY_ID
By.IOS_PREDICATE_STRING = MobileBy.IOS_PREDICATE_STRING

@property
def contexts(self):
Expand Down Expand Up @@ -98,6 +99,28 @@ def find_elements_by_ios_uiautomation(self, uia_string):
"""
return self.find_elements(by=By.IOS_UIAUTOMATION, value=uia_string)

def find_element_by_ios_predicate_string(self, predicate_string):
"""Finds an element by predicate string in iOS.

:Args:
- predicate_string - ????

:Usage:
driver.find_element_by_predicate_string('?????')
"""
return self.find_element(by=By.IOS_PREDICATE_STRING, value=predicate_string)

def find_elements_by_ios_predicate_string(self, predicate_string):
"""Finds elements by predicate string in iOS.

:Args:
- predicate_string - ????

:Usage:
driver.find_element_by_predicate_string('?????')
"""
return self.find_elements(by=By.IOS_PREDICATE_STRING, value=predicate_string)

def find_element_by_android_uiautomator(self, uia_string):
"""Finds element by uiautomator in Android.

Expand Down
22 changes: 22 additions & 0 deletions appium/webdriver/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@ def find_elements_by_ios_uiautomation(self, uia_string):
"""
return self.find_elements(by=By.IOS_UIAUTOMATION, value=uia_string)

def find_element_by_ios_predicate_string(self, predicate_string):
"""Finds an element by predicate string in iOS.

:Args:
- predicate_string - ????

:Usage:
driver.find_element_by_predicate_string('?????')
"""
return self.find_element(by=By.IOS_PREDICATE_STRING, value=predicate_string)

def find_elements_by_ios_predicate_string(self, predicate_string):
"""Finds elements by predicate string in iOS.

:Args:
- predicate_string - ????

:Usage:
driver.find_element_by_predicate_string('?????')
"""
return self.find_elements(by=By.IOS_PREDICATE_STRING, value=predicate_string)

def find_element_by_android_uiautomator(self, uia_string):
"""Finds element by uiautomator in Android.

Expand Down
34 changes: 34 additions & 0 deletions test/functional/ios/find_by_predicatestring_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from appium import webdriver
import desired_capabilities


class FindByPredicateStringTests(unittest.TestCase):
def setUp(self):
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

def tearDown(self):
self.driver.quit()

def test_find_single_element(self):
pass

if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(FindByPredicateStringTests)
unittest.TextTestRunner(verbosity=2).run(suite)